@ryanforever/url-filter
v1.0.1
Published
create a list of valid URLs, and check an input URL against them
Downloads
1
Readme
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