Skip to content

Commit

Permalink
Merge pull request #1487 from BolajiOlajide/ft-allow-square-brackets-…
Browse files Browse the repository at this point in the history
…param-url-validator

Allow square braces in URL validation
  • Loading branch information
Marsup committed Jun 29, 2018
2 parents 37d3588 + e6c09c9 commit 7aa0df0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/types/string/rfc3986.js
Expand Up @@ -78,6 +78,11 @@ internals.generate = function () {
const pchar = unreserved + pctEncoded + subDelims + ':@';
const pcharOnly = '[' + pchar + ']';

/**
* squareBraces example: []
*/
const squareBraces = '\\[\\]';

/**
* dec-octet = DIGIT ; 0-9
* / %x31-39 DIGIT ; 10-99
Expand Down Expand Up @@ -195,7 +200,7 @@ internals.generate = function () {
/**
* query = *( pchar / "/" / "?" )
*/
internals.rfc3986.query = '[' + pchar + '\\/\\?]*(?=#|$)'; //Finish matching either at the fragment part or end of the line.
internals.rfc3986.query = '[' + pchar + squareBraces + '\\/\\?]*(?=#|$)'; //Finish matching either at the fragment part or end of the line.

/**
* fragment = *( pchar / "/" / "?" )
Expand Down
1 change: 1 addition & 0 deletions test/types/string.js
Expand Up @@ -2523,6 +2523,7 @@ describe('string', () => {

Helper.validate(schema, [
['foo://example.com:8042/over/there?name=ferret#nose', true],
['https://example.com?abc[]=123&abc[]=456', true],
['urn:example:animal:ferret:nose', true],
['ftp://ftp.is.co.za/rfc/rfc1808.txt', true],
['http://www.ietf.org/rfc/rfc2396.txt', true],
Expand Down

0 comments on commit 7aa0df0

Please sign in to comment.