From 49e8df25aca26c50da0a334709dd2e31cd0644cb Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 17 Feb 2023 22:21:13 +0000 Subject: [PATCH] ie11: support back button --- copyparty/web/util.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/copyparty/web/util.js b/copyparty/web/util.js index f3565703..88e5139d 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -331,6 +331,25 @@ if (!String.prototype.format) }); }; +try { + new URL('/a/', 'https://a.com/'); +} +catch (ex) { + console.log('ie11 shim URL()'); + window.URL = function (url, base) { + if (url.indexOf('//') < 0) + url = base + '/' + url.replace(/^\/?/, ''); + else if (url.indexOf('//') == 0) + url = 'https:' + url; + + var x = url.split('?'); + return { + "pathname": '/' + x[0].split('://')[1].replace(/[^/]+\//, ''), + "search": x.length > 1 ? x[1] : '' + }; + } +} + // https://stackoverflow.com/a/950146 function import_js(url, cb) { var head = document.head || document.getElementsByTagName('head')[0];