parent
e4f94f0678
commit
9dc1d6ae81
|
@ -426,13 +426,12 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||||
return window.location;
|
return window.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBaseHref() {
|
String getBaseHref() {
|
||||||
var href = getBaseElementHref();
|
var href = getBaseElementHref();
|
||||||
if (href == null) {
|
if (href == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var baseUri = Uri.parse(href);
|
return _relativePath(href);
|
||||||
return baseUri.path[0] == '/' ? baseUri.path : ('/' + baseUri.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetBaseElement() {
|
resetBaseElement() {
|
||||||
|
@ -487,3 +486,14 @@ String getBaseElementHref() {
|
||||||
}
|
}
|
||||||
return baseElement.getAttribute('href');
|
return baseElement.getAttribute('href');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// based on urlUtils.js in AngularJS 1
|
||||||
|
AnchorElement _urlParsingNode = null;
|
||||||
|
String _relativePath(String url) {
|
||||||
|
if (_urlParsingNode == null) {
|
||||||
|
_urlParsingNode = new AnchorElement();
|
||||||
|
}
|
||||||
|
_urlParsingNode.href = url;
|
||||||
|
var pathname = _urlParsingNode.pathname;
|
||||||
|
return (pathname[0] == '/') ? pathname : '/${pathname}';
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue