throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
}
+ // Copy chrome, IE, opera backslash-handling behavior.
+ // See: https://code.google.com/p/chromium/issues/detail?id=25916
+ var hashSplit = url.split('#');
+ hashSplit[0] = hashSplit[0].replace(/\\/g, '/');
+ url = hashSplit.join('#');
+
var rest = url;
// trim before proceeding.
'path': '//some_path'
},
+ 'http:\\\\evil-phisher\\foo.html#h\\a\\s\\h': {
+ protocol: 'http:',
+ slashes: true,
+ host: 'evil-phisher',
+ hostname: 'evil-phisher',
+ pathname: '/foo.html',
+ path: '/foo.html',
+ hash: '#h\\a\\s\\h',
+ href: 'http://evil-phisher/foo.html#h\\a\\s\\h'
+ },
+
+
+ 'http:\\\\evil-phisher\\foo.html': {
+ protocol: 'http:',
+ slashes: true,
+ host: 'evil-phisher',
+ hostname: 'evil-phisher',
+ pathname: '/foo.html',
+ path: '/foo.html',
+ href: 'http://evil-phisher/foo.html'
+ },
+
'HTTP://www.example.com/' : {
'href': 'http://www.example.com/',
'protocol': 'http:',
'format(' + relativeTest[1] + ') == ' + expected +
'\nactual:' + actual);
});
+
+// backslashes should be like forward slashes
+var res = url.resolve('http://example.com/x', '\\\\foo.com\\bar');
+assert.equal(res, 'http://foo.com/bar');