@@ -42,6 +42,8 @@ export class Location {
4242 * @param {string } appBaseNoFile application base URL stripped of any filename
4343 */
4444 constructor ( appBase , appBaseNoFile ) {
45+ const parsedUrl = urlResolve ( appBase ) ;
46+
4547 /** @type {string } */
4648 this . appBase = appBase ;
4749
@@ -67,16 +69,17 @@ export class Location {
6769 this . $$replace = false ;
6870
6971 /** @type {import('../url-utils/url-utils').HttpProtocol } */
70- this . $$protocol = undefined ;
72+ this . $$protocol = parsedUrl . protocol ;
7173
7274 /** @type {string } */
73- this . $$host = undefined ;
75+ this . $$host = parsedUrl . hostname ;
7476
7577 /**
7678 * The port, without ":"
7779 * @type {number }
7880 */
79- this . $$port = undefined ;
81+ this . $$port =
82+ toInt ( parsedUrl . port ) || DEFAULT_PORTS [ parsedUrl . protocol ] || null ;
8083
8184 /**
8285 * The pathname, beginning with "/"
@@ -359,7 +362,6 @@ export class LocationHtml5Url extends Location {
359362 super ( appBase , appBaseNoFile ) ;
360363 this . $$html5 = true ;
361364 this . basePrefix = basePrefix || "" ;
362- parseAbsoluteUrl ( appBase , this ) ;
363365 }
364366
365367 /**
@@ -442,10 +444,7 @@ export class LocationHtml5Url extends Location {
442444export class LocationHashbangUrl extends Location {
443445 constructor ( appBase , appBaseNoFile , hashPrefix ) {
444446 super ( appBase , appBaseNoFile ) ;
445- this . appBase = appBase ;
446- this . appBaseNoFile = appBaseNoFile ;
447447 this . hashPrefix = hashPrefix ;
448- parseAbsoluteUrl ( appBase , this ) ;
449448 }
450449
451450 /**
@@ -890,19 +889,6 @@ function normalizePath(pathValue, searchValue, hashValue) {
890889 return path + ( search ? `?${ search } ` : "" ) + hash ;
891890}
892891
893- /**
894- * @param {string } absoluteUrl
895- * @param {Location } locationObj
896- */
897- function parseAbsoluteUrl ( absoluteUrl , locationObj ) {
898- const parsedUrl = urlResolve ( absoluteUrl ) ;
899-
900- locationObj . $$protocol = parsedUrl . protocol ;
901- locationObj . $$host = parsedUrl . hostname ;
902- locationObj . $$port =
903- toInt ( parsedUrl . port ) || DEFAULT_PORTS [ parsedUrl . protocol ] || null ;
904- }
905-
906892function parseAppUrl ( url , locationObj , html5Mode ) {
907893 if ( / ^ \s * [ \\ / ] { 2 , } / . test ( url ) ) {
908894 throw $locationMinErr ( "badpath" , 'Invalid url "{0}".' , url ) ;
0 commit comments