diff --git a/package-lock.json b/package-lock.json index 759daa37e2..a8f7a845fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "phoenix", - "version": "3.1.21-0", + "version": "3.1.22-0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "phoenix", - "version": "3.1.21-0", + "version": "3.1.22-0", "dependencies": { "@bugsnag/js": "^7.18.0", "@floating-ui/dom": "^0.5.4", diff --git a/src/phoenix/virtualServer/config.js b/src/phoenix/virtualServer/config.js index a1279fdb67..d99b90f398 100644 --- a/src/phoenix/virtualServer/config.js +++ b/src/phoenix/virtualServer/config.js @@ -33,7 +33,6 @@ if(!self.Config){ * * `debug`: if present (i.e., `Boolean`), enable workbox debug logging */ - const url = new URL(location); /** * Given a route string, make sure it follows the pattern we expect: @@ -47,7 +46,7 @@ if(!self.Config){ * @param {String} route */ function getNormalizeRoute() { - let route = url.searchParams.get('route') || 'fs'; + let route = (new URL(location)).searchParams.get('route') || 'fs'; // Only a single / at the front of the route route = route.replace(/^\/*/, ''); @@ -59,7 +58,7 @@ if(!self.Config){ self.Config = { route: getNormalizeRoute(), - disableIndexes: url.searchParams.get('disableIndexes') !== null, + disableIndexes: (new URL(location)).searchParams.get('disableIndexes') !== null, debug: false // this is set via sw messages from phoenix }; } diff --git a/src/phoenix/virtualServer/content-type.js b/src/phoenix/virtualServer/content-type.js index 4b6ec53a01..775a622c45 100644 --- a/src/phoenix/virtualServer/content-type.js +++ b/src/phoenix/virtualServer/content-type.js @@ -17,46 +17,48 @@ * */ -/* global lookup, importScripts*/ +/* global mime, importScripts*/ importScripts('phoenix/virtualServer/mime-types.js'); if(!self.ContentType){ - function getMimeType(path) { - return lookup(path) || 'application/octet-stream'; - } - - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#Audio_and_video_types - function isMedia(path) { - let mimeType = lookup(path); - if (!mimeType) { - return false; + (function () { + function getMimeType(path) { + return mime.lookup(path) || 'application/octet-stream'; } - mimeType = mimeType.toLowerCase(); + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#Audio_and_video_types + function isMedia(path) { + let mimeType = mime.lookup(path); + if (!mimeType) { + return false; + } - // Deal with OGG special case - if (mimeType === 'application/ogg') { - return true; - } + mimeType = mimeType.toLowerCase(); - // Anything else with `audio/*` or `video/*` is "media" - return mimeType.startsWith('audio/') || mimeType.startsWith('video/'); - } + // Deal with OGG special case + if (mimeType === 'application/ogg') { + return true; + } - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#Image_types - function isImage(path) { - const mimeType = lookup(path); - if (!mimeType) { - return false; + // Anything else with `audio/*` or `video/*` is "media" + return mimeType.startsWith('audio/') || mimeType.startsWith('video/'); } - return mimeType.toLowerCase().startsWith('image/'); - } + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#Image_types + function isImage(path) { + const mimeType = mime.lookup(path); + if (!mimeType) { + return false; + } + + return mimeType.toLowerCase().startsWith('image/'); + } - self.ContentType = { - isMedia, - isImage, - getMimeType - }; + self.ContentType = { + isMedia, + isImage, + getMimeType + }; + }()); } diff --git a/src/phoenix/virtualServer/html-formatter.js b/src/phoenix/virtualServer/html-formatter.js index b8dada03ba..59ff3643a4 100644 --- a/src/phoenix/virtualServer/html-formatter.js +++ b/src/phoenix/virtualServer/html-formatter.js @@ -23,44 +23,45 @@ importScripts('phoenix/virtualServer/content-type.js'); importScripts('phoenix/virtualServer/icons.js'); if(!self.HtmlFormatter){ -// 20-Apr-2004 17:14 - const formatDate = d => { - const day = d.getDate(); - const month = d.toLocaleString('en-us', {month: 'short'}); - const year = d.getFullYear(); - const hours = d.getHours(); - const mins = d.getMinutes(); - return `${day}-${month}-${year} ${hours}:${mins}`; - }; - - const formatSize = s => { - const units = ['', 'K', 'M']; - if (!s) { - return '-'; - } - const i = Math.floor(Math.log(s) / Math.log(1024)); - return Math.round(s / Math.pow(1024, i), 2) + units[i]; - }; - - const formatRow = ( - icon, - alt = '[ ]', - href, - name, - modified, - size - ) => `