Skip to content
This repository was archived by the owner on Aug 9, 2018. It is now read-only.

Commit 45c1d85

Browse files
committed
Mimic the behavior of UrlResolve
Angular UrlResovle that is using the DOM to parse the URL has a certain behavior to handle the value null. It results in the URI '/null' Mimic that behavior here instead of dying with: TypeError: Parameter 'url' must be a string, not object at Url.parse (url.js:118:11) at urlParse (url.js:112:5) at Url.resolve (url.js:406:29) at Object.urlResolve [as resolve] (url.js:402:40) at sanitizeUri (/Users/aimbert/devel/phoenix/node_modules/angularjs-server/lib/ngoverrides.js:589:45)
1 parent 2e55127 commit 45c1d85

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/ngoverrides.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,16 @@ function registerModule(context) {
586586
}
587587

588588
var baseUrl = serverRequestContext.location.absUrl();
589-
var normalizedVal = url.resolve(baseUrl, uri);
589+
590+
// mimic the behavior of UrlResolve
591+
var normalizedVal;
592+
if (uri === null) {
593+
normalizedVal = url.resolve(baseUrl, '/null');
594+
}
595+
else {
596+
normalizedVal = url.resolve(baseUrl, uri);
597+
}
598+
590599
if (normalizedVal !== '' && !normalizedVal.match(regex)) {
591600
return 'unsafe:' + normalizedVal;
592601
}

0 commit comments

Comments
 (0)