Skip to content

Commit 0e3fb54

Browse files
committed
[fix] Strip all control characters from the beginning of the URL
1 parent 61864a8 commit 0e3fb54

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var required = require('requires-port')
66
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
77
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
88
, windowsDriveLetter = /^[a-zA-Z]:/
9-
, whitespace = /^[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
9+
, whitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
1010

1111
/**
1212
* Trim a given string.

test/test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ describe('url-parse', function () {
4747
assume(parse.trimLeft).is.a('function');
4848
});
4949

50-
it('removes whitespace on the left', function () {
51-
assume(parse.trimLeft(' lol')).equals('lol');
50+
it('removes control characters on the left', function () {
51+
var i = 0;
52+
var prefix = ''
53+
54+
for (; i < 33; i++) {
55+
prefix = String.fromCharCode(i);
56+
assume(parse.trimLeft(prefix + prefix +'lol')).equals('lol');
57+
}
5258
});
5359

5460
it('calls toString on a given value', function () {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy