@ryanforever/url-filter

1.0.1 • Public • Published

url-filter

create a list of valid URLs, and check an input URL against them

usage

let UrlFilter = require("@ryanforever/url-filter")

// enter your the base urls of which you want to be valid input
let urlFilter = new UrlFilter({
    instagram: ["instagram.com"],
    reddit: ["reddit.com", "redd.it"],
    soundcloud: ["soundcloud.com"],
    youtube: ["youtube.com", "youtu.be"],
    pinterest: ["pinterest.com", "pin.it"],
    tiktok: ["tiktok.com"]
})

// checks if the input url exists in the valid urls
urlFilter.has("www.pinterest.com")
// true

// gets the name of the website for the input url
urlFilter.get("https://youtube.com")
// youtube

// formats a url with the given prefix
urlFilter.format("http://tiktok.com/", "https://www.")
// https://www.tiktok.com/

// checks if url is http
urlFilter.isHttp("www.soundcloud.com")
// false

// checks if url is https
urlFilter.isHttps("https://youtube.com")
// true

Readme

Keywords

Package Sidebar

Install

npm i @ryanforever/url-filter

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

4.85 kB

Total Files

6

Last publish

Collaborators

  • ryanforever