From 82f60928b434ad9b837fea8d0b85cbb4ae465e63 Mon Sep 17 00:00:00 2001 From: Kieran Hall Date: Thu, 24 Oct 2024 13:47:54 +0200 Subject: [PATCH] explorer: Add staging URL into node URL function --- .../src/lib/url/__tests__/makeNodeUrl.spec.js | 16 ++++++++++++++++ explorer/src/lib/url/makeNodeUrl.js | 1 + 2 files changed, 17 insertions(+) diff --git a/explorer/src/lib/url/__tests__/makeNodeUrl.spec.js b/explorer/src/lib/url/__tests__/makeNodeUrl.spec.js index 0b97bf49e..eac9fdd2b 100644 --- a/explorer/src/lib/url/__tests__/makeNodeUrl.spec.js +++ b/explorer/src/lib/url/__tests__/makeNodeUrl.spec.js @@ -152,4 +152,20 @@ describe("makeNodeUrl", () => { expect(makeNodeUrl().hostname).toBe("nodes.dusk.network"); }); + + it("should return the mainnet URL when the hostname starts with 'staging.apps'", () => { + global.window = Object.create(window); + + const url = new URL("https://staging.apps.dusk.network"); + + Object.defineProperty(window, "location", { + value: { + hostname: url.hostname, + href: url.href, + protocol: url.protocol, + }, + }); + + expect(makeNodeUrl().hostname).toBe("nodes.dusk.network"); + }); }); diff --git a/explorer/src/lib/url/makeNodeUrl.js b/explorer/src/lib/url/makeNodeUrl.js index 99fcda976..2079a1f0e 100644 --- a/explorer/src/lib/url/makeNodeUrl.js +++ b/explorer/src/lib/url/makeNodeUrl.js @@ -27,6 +27,7 @@ function makeNodeUrl(path = "") { switch (subDomains[0]) { case "apps": // mainnet + case "staging": // mainnet staging nodeUrl = buildHostedNodeUrl("nodes."); break; case "devnet":