From 42cea844a8743717f55c6fcbb6e413573dff22f6 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 5 May 2024 23:00:09 +0800 Subject: [PATCH] add URL cleaning external function --- scripts/utils/URLs.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scripts/utils/URLs.js diff --git a/scripts/utils/URLs.js b/scripts/utils/URLs.js new file mode 100644 index 0000000..bd8e069 --- /dev/null +++ b/scripts/utils/URLs.js @@ -0,0 +1,16 @@ +/* +URL tools +*/ + +class URLs { + /* + Remove the protocol from the URL. + + @param {string} URL the URL to clean + */ + static clean(URL) { + return((URL.trim().replace(/(^\w+:|^)\/\//, ``).split(`?`))[0]); + } +} + +export {URLs}; \ No newline at end of file