From c923b2f1c64a89a6a8aed3be99f5b2f7d8aa19d2 Mon Sep 17 00:00:00 2001 From: Wouter Van Hemel Date: Tue, 20 Jun 2017 19:00:18 +0300 Subject: [PATCH 1/2] Fix String object length bug Both node and Firefox don't seem to allow overriding String.length, resulting in length returning zero for (the outer) string objects. This shows for instance by the domain not being stripped from the path or empty paths. Tests pass again after this fix. --- uris.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uris.js b/uris.js index b3a7831..9aa2070 100644 --- a/uris.js +++ b/uris.js @@ -122,7 +122,7 @@ removeDotSegments: function( input ) { var output = ''; var q = null; - while( input.length > 0 ) { + while( input.toString().length > 0 ) { if( input.substr(0,3) == '../' || input.substr(0,2) == './' ) { input = input.slice(input.indexOf('/')); } else if( input == '/.' ) { @@ -272,7 +272,7 @@ path: function() { var q = this.authority(); if( !q ) return new URI.Path(this); - return new URI.Path( this.slice(q.length + 2) ); + return new URI.Path( this.slice(q.toString().length + 2) ); } }; From 5539eb54ec16944d2148d3e6946c05f8a1d3e946 Mon Sep 17 00:00:00 2001 From: Wouter Van Hemel Date: Tue, 20 Jun 2017 19:09:01 +0300 Subject: [PATCH 2/2] Don't append the string 'null' for the scheme when creating a new URI in resolveReference() --- uris.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uris.js b/uris.js index 9aa2070..32e0335 100644 --- a/uris.js +++ b/uris.js @@ -227,7 +227,7 @@ q = this.heirpart().authority(); T.authority = q ? '//' + q : ''; } - T.scheme = this.scheme(); + T.scheme = this.scheme() || ''; } q = reference.fragment(); T.fragment = q ? q : '';