aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/urlUtils.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ng/urlUtils.js')
-rw-r--r--src/ng/urlUtils.js48
1 files changed, 4 insertions, 44 deletions
diff --git a/src/ng/urlUtils.js b/src/ng/urlUtils.js
index cba8981c..3169248f 100644
--- a/src/ng/urlUtils.js
+++ b/src/ng/urlUtils.js
@@ -7,11 +7,6 @@
// exactly the behavior needed here. There is little value is mocking these out for this
// service.
var urlParsingNode = document.createElement("a");
-/*
-Matches paths for file protocol on windows,
-such as /C:/foo/bar, and captures only /foo/bar.
-*/
-var windowsFilePathExp = /^\/?.*?:(\/.*)/;
var originUrl = urlResolve(window.location.href, true);
@@ -68,8 +63,7 @@ var originUrl = urlResolve(window.location.href, true);
*
*/
function urlResolve(url, base) {
- var href = url,
- pathname;
+ var href = url;
if (msie) {
// Normalize before parse. Refer Implementation Notes on why this is
@@ -80,21 +74,6 @@ function urlResolve(url, base) {
urlParsingNode.setAttribute('href', href);
- /*
- * In Windows, on an anchor node on documents loaded from
- * the filesystem, the browser will return a pathname
- * prefixed with the drive name ('/C:/path') when a
- * pathname without a drive is set:
- * * a.setAttribute('href', '/foo')
- * * a.pathname === '/C:/foo' //true
- *
- * Inside of Angular, we're always using pathnames that
- * do not include drive names for routing.
- */
-
- pathname = removeWindowsDriveName(urlParsingNode.pathname, url, base);
- pathname = (pathname.charAt(0) === '/') ? pathname : '/' + pathname;
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
@@ -104,11 +83,12 @@ function urlResolve(url, base) {
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
- pathname: pathname
+ pathname: (urlParsingNode.pathname.charAt(0) === '/')
+ ? urlParsingNode.pathname
+ : '/' + urlParsingNode.pathname
};
}
-
/**
* Parse a request URL and determine whether this is a same-origin request as the application document.
*
@@ -121,23 +101,3 @@ function urlIsSameOrigin(requestUrl) {
return (parsed.protocol === originUrl.protocol &&
parsed.host === originUrl.host);
}
-
-function removeWindowsDriveName (path, url, base) {
- var firstPathSegmentMatch;
-
- //Get the relative path from the input URL.
- if (url.indexOf(base) === 0) {
- url = url.replace(base, '');
- }
-
- /*
- * The input URL intentionally contains a
- * first path segment that ends with a colon.
- */
- if (windowsFilePathExp.exec(url)) {
- return path;
- }
-
- firstPathSegmentMatch = windowsFilePathExp.exec(path);
- return firstPathSegmentMatch ? firstPathSegmentMatch[1] : path;
-} \ No newline at end of file