custom-url-check
Version:
🐜 Simple NPM package to check if a string is valid and a specific community URL!
70 lines (51 loc) • 1.74 kB
Markdown
"center">🐜</p>
<p align="center"><a href="https://nodei.co/npm/custom-url-check/"><img src="https://nodei.co/npm/custom-url-check.png"></a></p>
* Simple NPM package to check a string for a valid custom filtered URL!
* See examples below
`$ npm i custom-url-check `
- Returns a Boolean indicating whether `string` is a valid URL and contains the specified community `filter`
- `filter` parameter is case-insensitive
```javascript
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');
```
```javascript
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! ❌');
}
});
```
<p align="center">
<img src="https://i.imgur.com/2B0b4nQ.png"><br/>
</p>
<p align="center">🐜</p>
<p align=