custom-url-check
v1.4.0
Published
π Simple NPM package to check if a string is valid and a specific community URL!
Downloads
91
Maintainers
Readme
custom-url-check
- Simple NPM package to check a string for a valid custom filtered URL!
- See examples below
Install via NPM
$ npm i custom-url-check
Usage
- Returns a Boolean indicating whether
string
is a valid URL and contains the specified communityfilter
filter
parameter is case-insensitive
const customUrl = require('custom-url-check');
// --| customURL(url, filter);
// --| The below URL is not a valid YouTube URL
customUrl('amazon.co.uk', 'youtube');
customUrl('www.google.pl', 'YouTube');
customUrl('https://www.github.com', 'youtube');
// --| customURL(url, filter);
// --| The below URL is a valid YouTube URL
customUrl('https://www.youtube.com/', 'YouTube');
customUrl('www.youtube.com', 'youtube');
customUrl('youtube.com', 'YouTUBE');
customUrl('https://www.youtube.com/watch?v=w3jLJU7DT5E', 'Youtube');
Example
const customUrl = require('custom-url-check');
const testUrl = [
'https://www.npmjs.com/',
'www.googl.co.uk',
'www.youtube.ro',
'http://google.com',
'https://www.google.com',
'http://www.google.com',
'www.google.com',
'google.com'
];
testUrl.forEach((element) => {
if (customUrl(element, 'GoOgLe')) {
console.log(element + ' It\'s a valid Google URL! β
');
}
else {
console.log(element + ' Is not a valid Google URL! β');
}
});