1.0.1 • Published 2 years ago

@ryanforever/url-filter v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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
1.0.1

2 years ago

1.0.0

2 years ago