Skip to content

Commit

Permalink
Support commas in URLs (#76)
Browse files Browse the repository at this point in the history
* commas should also be supported in URLs

* Update URL validation regex: commas should be available characters

* Update URL validation regex: braces should also be available characters
  • Loading branch information
Datrio authored and stojanovic committed Jan 6, 2017
1 parent 0abb765 commit 7a2eb92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/is-url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = function isUrl(url) {
const pattern = /^[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,63}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?$/gi;
const pattern = /^[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,63}\b(\/[-a-zA-Z0-9@:%_\(\)\+.,~#?&//=]*)?$/gi;
return pattern.test(url);
};
1 change: 1 addition & 0 deletions spec/is-url-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('isUrl', () => {
expect(isUrl('https://www.claudiajs.com')).toBeTruthy();
expect(isUrl('https://github.com/claudiajs')).toBeTruthy();
expect(isUrl('https://github.com/claudiajs/claudia-bot-builder')).toBeTruthy();
expect(isUrl('https://www.google.com/#q=claudia,bot')).toBeTruthy();
});
it('should return false if url is in the sentence', () => {
expect(isUrl('This is a valid url: http://google.com')).toBeFalsy();
Expand Down

0 comments on commit 7a2eb92

Please sign in to comment.