custom-url-check
TypeScript icon, indicating that this package has built-in type declarations

1.3.0Β β€’Β PublicΒ β€’Β Published

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 community filter
  • 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! ❌');
    }
});

Result of the example above


🐜

Package Sidebar

Install

npm i custom-url-check

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

8.13 kB

Total Files

7

Last publish

Collaborators

  • tutyamxx