File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -342,8 +342,11 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
342342 return window.location;
343343 }
344344 getBaseHref () {
345- var uri = document.baseUri;
346- var baseUri = Uri .parse (uri);
345+ var href = getBaseElementHref ();
346+ if (href == null ) {
347+ return null ;
348+ }
349+ var baseUri = Uri .parse (href);
347350 return baseUri.path;
348351 }
349352 String getUserAgent () {
@@ -360,3 +363,15 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
360363 js.context[name] = value;
361364 }
362365}
366+
367+
368+ var baseElement = null ;
369+ String getBaseElementHref () {
370+ if (baseElement == null ) {
371+ baseElement = document.querySelector ('base' );
372+ if (baseElement == null ) {
373+ return null ;
374+ }
375+ }
376+ return baseElement.getAttribute ('href' );
377+ }
Original file line number Diff line number Diff line change @@ -263,14 +263,32 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
263263 }
264264 getHistory ( ) : History { return window . history ; }
265265 getLocation ( ) : Location { return window . location ; }
266- getBaseHref ( ) : string { return relativePath ( document . baseURI ) ; }
266+ getBaseHref ( ) : string {
267+ var href = getBaseElementHref ( ) ;
268+ if ( isBlank ( href ) ) {
269+ return null ;
270+ }
271+ return relativePath ( href ) ;
272+ }
267273 getUserAgent ( ) : string { return window . navigator . userAgent ; }
268274 setData ( element , name : string , value : string ) { element . dataset [ name ] = value ; }
269275 getData ( element , name : string ) : string { return element . dataset [ name ] ; }
270276 // TODO(tbosch): move this into a separate environment class once we have it
271277 setGlobalVar ( name : string , value : any ) { global [ name ] = value ; }
272278}
273279
280+
281+ var baseElement = null ;
282+ function getBaseElementHref ( ) : string {
283+ if ( isBlank ( baseElement ) ) {
284+ baseElement = document . querySelector ( 'base' ) ;
285+ if ( isBlank ( baseElement ) ) {
286+ return null ;
287+ }
288+ }
289+ return baseElement . attr ( 'href' ) ;
290+ }
291+
274292// based on urlUtils.js in AngularJS 1
275293var urlParsingNode = null ;
276294function relativePath ( url ) : string {
You can’t perform that action at this time.
0 commit comments