Skip to content

Commit 9bcb964

Browse files
committed
Merge pull request #242 from lpinca/simplify/url-sanitization
Simplify the URL sanitization
2 parents fdf37da + cd626d3 commit 9bcb964

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ function SockJS(url, protocols, options) {
9292
this._origin = o ? o.toLowerCase() : null;
9393

9494
// remove the trailing slash
95-
parsedUrl.path = parsedUrl.pathname.replace(/[/]+$/, '') + (parsedUrl.query || '');
95+
parsedUrl.set('pathname', parsedUrl.pathname.replace(/\/+$/, ''));
9696

9797
// store the sanitized url
98-
this.url = parsedUrl.protocol + '//' + (parsedUrl.auth ? parsedUrl.auth + '@' : '') +
99-
parsedUrl.hostname + (parsedUrl.port ? ':' + parsedUrl.port : '') + parsedUrl.path;
98+
this.url = parsedUrl.href;
10099
debug('using url', this.url);
101100

102101
// Step 7 - start connection in background

0 commit comments

Comments
 (0)