From 02a5c628e96375589e3d894aff84f38bebe66929 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sun, 31 Dec 2017 14:42:45 +0200 Subject: [PATCH] Add isAbsoluteURL --- snippets/isAbsoluteURL.md | 15 +++++++++++++++ tag_database | 1 + 2 files changed, 16 insertions(+) create mode 100644 snippets/isAbsoluteURL.md diff --git a/snippets/isAbsoluteURL.md b/snippets/isAbsoluteURL.md new file mode 100644 index 000000000..8f13f5861 --- /dev/null +++ b/snippets/isAbsoluteURL.md @@ -0,0 +1,15 @@ +### isAbsoluteURL + +Returns `true` if the given string is an absolute URL, `false` otherwise. + +Use a regular expression to test if the string is an absolute URL. + +```js +const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); +``` + +```js +isAbsoluteURL('https://google.com'); // true +isAbsoluteURL('ftp://www.myserver.net'); // true +isAbsoluteURL('/foo/bar'); // false +``` diff --git a/tag_database b/tag_database index e2bb75c7e..716ff171b 100644 --- a/tag_database +++ b/tag_database @@ -64,6 +64,7 @@ initializeArrayWithRange:array initializeArrayWithValues:array inRange:math intersection:array +isAbsoluteURL:string isArmstrongNumber:math isArray:utility isBoolean:utility