File tree Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -318,4 +318,9 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
318318 getLocation () {
319319 return window.location;
320320 }
321+ getBaseHref () {
322+ var uri = document.baseUri;
323+ var baseUri = Uri .parse (uri);
324+ return baseUri.path;
325+ }
321326}
Original file line number Diff line number Diff line change @@ -381,4 +381,17 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
381381 getLocation ( ) {
382382 return window . location ;
383383 }
384+ getBaseHref ( ) {
385+ return relativePath ( document . baseURI ) ;
386+ }
387+ }
388+
389+ // based on urlUtils.js in AngularJS 1
390+ var urlParsingNode = null ;
391+ function relativePath ( url ) {
392+ if ( isBlank ( urlParsingNode ) ) {
393+ urlParsingNode = document . createElement ( "a" ) ;
394+ }
395+ urlParsingNode . setAttribute ( 'href' , url ) ;
396+ return ( urlParsingNode . pathname . charAt ( 0 ) === '/' ) ? urlParsingNode . pathname : '/' + urlParsingNode . pathname ;
384397}
Original file line number Diff line number Diff line change @@ -292,4 +292,7 @@ export class DomAdapter {
292292 getLocation ( ) {
293293 throw _abstract ( ) ;
294294 }
295+ getBaseHref ( ) {
296+ throw _abstract ( ) ;
297+ }
295298}
Original file line number Diff line number Diff line change @@ -297,4 +297,7 @@ class Html5LibDomAdapter implements DomAdapter {
297297 getLocation () {
298298 throw 'not implemented' ;
299299 }
300+ getBaseHref () {
301+ throw 'not implemented' ;
302+ }
300303}
You can’t perform that action at this time.
0 commit comments