Skip to content

Commit

Permalink
isURL
Browse files Browse the repository at this point in the history
  • Loading branch information
lholliger committed Oct 1, 2020
1 parent 35b6f62 commit ea9bbd3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Validate is a standard Deno module for validating string.
* [ ] isSurrogatePair
* [ ] isSvg
* [ ] isTaxID
* [ ] isURL
* [x] isURL
* [ ] isUUID
* [ ] isUppercase
* [ ] isVariableWidth
Expand Down
12 changes: 12 additions & 0 deletions src/libs/isURL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-ignore allowing typedoc to build
import assertString from '../utils/assertString.ts';

export const isURL = (str: string) => {
assertString(str);
try {
new URL(str);
} catch(err) {
return false;
}
return true;
};
2 changes: 2 additions & 0 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export * from './libs/isBtcAddress.ts';
export * from './libs/isByteLength.ts';
// @ts-ignore allowing typedoc to build
export * from './libs/isCreditCard.ts';
// @ts-ignore allowing typedoc to build
export * from './libs/isURL.ts';

0 comments on commit ea9bbd3

Please sign in to comment.