hd-utils
Version:
A handy utils for modern JS developers
12 lines (11 loc) • 362 B
JavaScript
import addHttpToURL from './addHttpToURL';
/**
* @description will make a new URL object for the passed url string.
* its like parseURL, more lightweight but with less functionalities.
*/
export default function getUrlObj(url) {
if (!(url.startsWith('http') || url.startsWith('https'))) {
url = addHttpToURL(url);
}
return new URL(url);
}