From 780a247d5fef1c42a0395d85e02df7a46983a431 Mon Sep 17 00:00:00 2001 From: Tommy Messbauer Date: Fri, 4 Jul 2014 14:24:05 -0700 Subject: [PATCH 1/2] replaced substr(-1) --- url.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/url.js b/url.js index ddc4ade..9324304 100644 --- a/url.js +++ b/url.js @@ -378,7 +378,7 @@ Url.prototype.format = function() { var search = this.search || (query && ('?' + query)) || ''; - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; + if (protocol && protocol.length && protocol[protocol.length - 1] !== ':') protocol += ':'; // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. // unless they had them to begin with. @@ -632,8 +632,11 @@ Url.prototype.resolveObject = function(relative) { srcPath.unshift(''); } - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); + if (hasTrailingSlash) { + var srcPathJoined = srcPath.join('/'); + if (srcPathJoined[srcPathJoined.length - 1] !== '/')) { + srcPath.push(''); + } } var isAbsolute = srcPath[0] === '' || From 54131368507dd921424916eed17f604a5ab62829 Mon Sep 17 00:00:00 2001 From: Tommy Messbauer Date: Fri, 4 Jul 2014 14:29:16 -0700 Subject: [PATCH 2/2] replaced substr(-1) --- url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/url.js b/url.js index 9324304..41d408d 100644 --- a/url.js +++ b/url.js @@ -634,7 +634,7 @@ Url.prototype.resolveObject = function(relative) { if (hasTrailingSlash) { var srcPathJoined = srcPath.join('/'); - if (srcPathJoined[srcPathJoined.length - 1] !== '/')) { + if (srcPathJoined[srcPathJoined.length - 1] !== '/') { srcPath.push(''); } }