File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 239239 // balanced parens inclusion (), [], {}, <>
240240 parens : / ( \( [ ^ \) ] * \) | \[ [ ^ \] ] * \] | \{ [ ^ } ] * \} | < [ ^ > ] * > ) / g,
241241 } ;
242+ URI . leading_whitespace_expression = / ^ [ \x00 - \x20 \u00a0 \u1680 \u2000 - \u200a \u2028 \u2029 \u202f \u205f \u3000 \ufeff ] + /
242243 // http://www.iana.org/assignments/uri-schemes.html
243244 // http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
244245 URI . defaultPorts = {
494495 preventInvalidHostname : URI . preventInvalidHostname
495496 } ;
496497 }
498+
499+ string = string . replace ( URI . leading_whitespace_expression , '' )
500+
497501 // [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment]
498502
499503 // extract fragment
Original file line number Diff line number Diff line change @@ -2571,6 +2571,55 @@ var urls = [{
25712571 idn : false ,
25722572 punycode : false
25732573 }
2574+ } , {
2575+ name : 'leading white space' ,
2576+ url : '\t\bhttp://www.example.org/?hello=world' ,
2577+ _url : 'http://www.example.org/?hello=world' ,
2578+ parts : {
2579+ protocol : 'http' ,
2580+ username : null ,
2581+ password : null ,
2582+ hostname : 'www.example.org' ,
2583+ port : null ,
2584+ path : '/' ,
2585+ query : 'hello=world' ,
2586+ fragment : null
2587+ } ,
2588+ accessors : {
2589+ protocol : 'http' ,
2590+ username : '' ,
2591+ password : '' ,
2592+ port : '' ,
2593+ path : '/' ,
2594+ query : 'hello=world' ,
2595+ fragment : '' ,
2596+ resource : '/?hello=world' ,
2597+ authority : 'www.example.org' ,
2598+ origin : 'http://www.example.org' ,
2599+ userinfo : '' ,
2600+ subdomain : 'www' ,
2601+ domain : 'example.org' ,
2602+ tld : 'org' ,
2603+ directory : '/' ,
2604+ filename : '' ,
2605+ suffix : '' ,
2606+ hash : '' ,
2607+ search : '?hello=world' ,
2608+ host : 'www.example.org' ,
2609+ hostname : 'www.example.org'
2610+ } ,
2611+ is : {
2612+ urn : false ,
2613+ url : true ,
2614+ relative : false ,
2615+ name : true ,
2616+ sld : false ,
2617+ ip : false ,
2618+ ip4 : false ,
2619+ ip6 : false ,
2620+ idn : false ,
2621+ punycode : false
2622+ }
25742623 }
25752624] ;
25762625
You can’t perform that action at this time.
0 commit comments