This PR adds two new helpers to refactor the URL validation and favicon URL generation logic out of the main js files.
Both helpers are documented with JSDoc, and extractBaseUrl.js has a few examples, too, to prevent confusion.
extractBaseUrl.js
This function takes a URL input and returns the base URL (what would be supplied as an Origin header when navigating). If the URL is invalid, it returns null.
isValidUrl.js
It basically does what the name says. If the URL is valid, it returns true, otherwise false. The URL API isn't supported in IE, but that shouldn't be a real issue: people using IE should expect many, many issues on modern sites.
This PR adds two new helpers to refactor the URL validation and favicon URL generation logic out of the main js files.
Both helpers are documented with JSDoc, and
extractBaseUrl.js
has a few examples, too, to prevent confusion.extractBaseUrl.js
This function takes a URL input and returns the base URL (what would be supplied as an
Origin
header when navigating). If the URL is invalid, it returnsnull
.isValidUrl.js
It basically does what the name says. If the URL is valid, it returns
true
, otherwisefalse
. The URL API isn't supported in IE, but that shouldn't be a real issue: people using IE should expect many, many issues on modern sites.