var url = require("url"); export class URL { // #region Properties protocol: string; host: string; port: string; path: string; querystring: string; href: string; // #endregion // #region Constructor constructor(url) { this.parse(url); } // #endregion // #region Actions parse(href) { var parsedUrl = url.parse(href); this.protocol = parsedUrl.protocol; this.host = parsedUrl.hostname; this.port = parsedUrl.port; if (this.port === null) { this.port = this.protocol === "http:" ? "80" : "443"; } this.path = parsedUrl.pathname; this.querystring = parsedUrl.search; this.href = parsedUrl.href; } // #endregion // #region Helper Methods // #endregion }