Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
window.fetch = function safeFetch() {
const args = [].slice.call(arguments);
const url = args[0];
try {
new window.URL(url);
} catch (error) {
args[0] = window.location.protocol + '//' + window.location.host + url;
}
return fetch.apply(null, args);
};