Skip to content

Commit

Permalink
Add support for safari web extension bundles
Browse files Browse the repository at this point in the history
Before we were able to determine the bundle url for chrome and firefox extensions.
This fix also supports safari.
  • Loading branch information
Kjoep committed May 25, 2022
1 parent a39abef commit 6b82317
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/runtimes/js/src/helpers/bundle-url.js
Expand Up @@ -14,7 +14,7 @@ function getBundleURL() {
throw new Error();
} catch (err) {
var matches = ('' + err.stack).match(
/(https?|file|ftp|(chrome|moz)-extension):\/\/[^)\n]+/g,
/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^)\n]+/g,
);
if (matches) {
// The first two stack frames will be this function and getBundleURLCached.
Expand All @@ -29,7 +29,7 @@ function getBundleURL() {
function getBaseURL(url) {
return (
('' + url).replace(
/^((?:https?|file|ftp|(chrome|moz)-extension):\/\/.+)\/[^/]+$/,
/^((?:https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/.+)\/[^/]+$/,
'$1',
) + '/'
);
Expand All @@ -38,7 +38,7 @@ function getBaseURL(url) {
// TODO: Replace uses with `new URL(url).origin` when ie11 is no longer supported.
function getOrigin(url) {
let matches = ('' + url).match(
/(https?|file|ftp|(chrome|moz)-extension):\/\/[^/]+/,
/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^/]+/,
);
if (!matches) {
throw new Error('Origin not found');
Expand Down

0 comments on commit 6b82317

Please sign in to comment.