@flourish/pocket-knife
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "@flourish/pocket-knife", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Flourish module with handy tools", | ||
@@ -5,0 +5,0 @@ "main": "pocket-knife.js", |
@@ -10,5 +10,5 @@ # Flourish pocket knife | ||
### isUrl(string) | ||
Checks if string is valid URL. Returns `null` if false. Otherwise returns matched value. | ||
Checks if string looks like valid URL. Returns `true` or `false` | ||
### isImage(string) | ||
Checks if string is valid image URL. Returns `null` if false. Otherwise returns matched value. | ||
Checks if string looks like valid image URL. Returns `true` or `false` |
@@ -0,2 +1,5 @@ | ||
### 0.2.0 | ||
* Improve string checker for isUrl and isImage | ||
### 0.1.0 | ||
* First version with isImage and isUrl functions |
@@ -1,15 +0,11 @@ | ||
function isUndefined(string) { | ||
return string === undefined || string === null; | ||
} | ||
function isUrl(string) { | ||
if (isUndefined(string)) return null; | ||
return string.match(/^https?:\/\//i); | ||
if (typeof string != "string") return false; | ||
return string.match(/^https?:\/\//i) != null; | ||
} | ||
function isImage(string) { | ||
if (isUndefined(string)) return null; | ||
return string.match(/^https?:\/\/.+\.(jpg|jpeg|svg|png|gif|webp)$/i); | ||
if (typeof string != "string") return false; | ||
return string.match(/^https?:\/\/.+\.(jpg|jpeg|svg|png|gif|webp)$/i) != null; | ||
} | ||
export { isUrl, isImage } |
2229
31