Skip to content

Commit

Permalink
Fix mobile version of is-url.
Browse files Browse the repository at this point in the history
Changes on this PR: #19871 broke the native `is-url` version since it won't throw if the given string is not a url.
  • Loading branch information
etoledom committed Feb 11, 2020
1 parent 8313c65 commit 330fda5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/url/src/is-url.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const URL_REGEXP = /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i;

/**
* Determines whether the given string looks like a URL.
*
* @param {string} url The string to scrutinise.
*
* @example
* ```js
* const isURL = isURL( 'https://wordpress.org' ); // true
* ```
*
* @return {boolean} Whether or not it looks like a URL.
*/
export function isURL( url ) {
return URL_REGEXP.test( url );
}

0 comments on commit 330fda5

Please sign in to comment.