Skip to content

Commit

Permalink
handle app store url scheme (#438)
Browse files Browse the repository at this point in the history
* handle app store url scheme

* Update scheme regex
  • Loading branch information
jdanyow authored and devongovett committed Dec 30, 2017
1 parent 0ab0aca commit 494fafc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/is-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const isURL = require('is-url');
// Matches anchor (ie: #raptors)
const ANCHOR_REGEXP = /^#/;

// Matches scheme (ie: tel:, mailto:, data:)
const SCHEME_REGEXP = /^[a-z]*:/i;
// Matches scheme (ie: tel:, mailto:, data:, itms-apps:)
const SCHEME_REGEXP = /^[a-z][a-z0-9\-+.]*:/i;

module.exports = function(url) {
return isURL(url) || ANCHOR_REGEXP.test(url) || SCHEME_REGEXP.test(url);
Expand Down
20 changes: 20 additions & 0 deletions test/is-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const assert = require('assert');
const isURL = require('../src/utils/is-url');

describe('isURL', () => {
it('should match url', () => {
assert(isURL('https://parceljs.org/'));
});

it('should match anchor', () => {
assert(isURL('#'));
assert(isURL('#foo'));
});

it('should match scheme-only', () => {
assert(isURL('tel:'));
assert(isURL('https:'));
assert(isURL('mailto:'));
assert(isURL('itms-apps:'));
});
});

0 comments on commit 494fafc

Please sign in to comment.