From 403a39b00daab593cb81b11085fb598472f551f3 Mon Sep 17 00:00:00 2001 From: webreflection Date: Mon, 7 Apr 2025 17:24:54 +0200 Subject: [PATCH 1/2] Fix #2326 - Redirect to localhost when on 0.0.0.0 --- core/src/core.js | 1 + core/src/zero-redirect.js | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 core/src/zero-redirect.js diff --git a/core/src/core.js b/core/src/core.js index e8bdf7e9007..83e7734bcce 100644 --- a/core/src/core.js +++ b/core/src/core.js @@ -1,5 +1,6 @@ /*! (c) PyScript Development Team */ +import "./zero-redirect.js"; import stickyModule from "sticky-module"; import "@ungap/with-resolvers"; diff --git a/core/src/zero-redirect.js b/core/src/zero-redirect.js new file mode 100644 index 00000000000..e692ca7fea8 --- /dev/null +++ b/core/src/zero-redirect.js @@ -0,0 +1,8 @@ +/* eslint no-unused-vars: 0 */ +try { + crypto.randomUUID(); +} +catch (_) { + if (location.href.startsWith('http://0.0.0.0')) + location.href = location.href.replace('0.0.0.0', 'localhost'); +} From 4c741a064825e293e280a69c42f83387c74f044c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:44:14 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- core/src/zero-redirect.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/zero-redirect.js b/core/src/zero-redirect.js index e692ca7fea8..ddc34f73d89 100644 --- a/core/src/zero-redirect.js +++ b/core/src/zero-redirect.js @@ -1,8 +1,7 @@ -/* eslint no-unused-vars: 0 */ -try { - crypto.randomUUID(); -} -catch (_) { - if (location.href.startsWith('http://0.0.0.0')) - location.href = location.href.replace('0.0.0.0', 'localhost'); -} +/* eslint no-unused-vars: 0 */ +try { + crypto.randomUUID(); +} catch (_) { + if (location.href.startsWith("http://0.0.0.0")) + location.href = location.href.replace("0.0.0.0", "localhost"); +}