X Tutup
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions modules/angular2/src/core/dom/browser_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,12 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
return window.location;
}

getBaseHref() {
String getBaseHref() {
var href = getBaseElementHref();
if (href == null) {
return null;
}
var baseUri = Uri.parse(href);
return baseUri.path[0] == '/' ? baseUri.path : ('/' + baseUri.path);
return _relativePath(href);
}

resetBaseElement() {
Expand Down Expand Up @@ -487,3 +486,14 @@ String getBaseElementHref() {
}
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}';
}
X Tutup