From 2e8097929e10f4eb4e705fb8777ec6dc429a7426 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Fri, 20 Sep 2024 09:13:22 -0400 Subject: [PATCH 1/2] fix: store routes --- src/middleware/parseUdi.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/middleware/parseUdi.ts b/src/middleware/parseUdi.ts index 075cc48..efed7e0 100644 --- a/src/middleware/parseUdi.ts +++ b/src/middleware/parseUdi.ts @@ -21,7 +21,6 @@ function removeDuplicatePathPart(path: string): string { } const modifiedPath = '/' + parts.join('/'); - console.log('Original path:', path); console.log('Modified path:', modifiedPath); @@ -40,8 +39,14 @@ export const parseUdi = async ( return next(); } - // **Apply removeDuplicatePathPart to the request path** - const modifiedPath = removeDuplicatePathPart(req.originalUrl); + // Extract the path and query string separately + const [path, queryString] = req.originalUrl.split("?"); + + // Apply removeDuplicatePathPart to the request path + const modifiedPath = removeDuplicatePathPart(path); + + // Re-append the query string if it exists + const modifiedUrl = queryString ? `${modifiedPath}?${queryString}` : modifiedPath; const referrer = req.get("Referer") || ""; let cookieData = req.cookies.udiData || null; @@ -50,7 +55,7 @@ export const parseUdi = async ( let storeId: string = ""; let rootHash: string | null = null; - // **Use modifiedPath instead of req.originalUrl** + // Use modifiedPath instead of req.originalUrl const pathSegments = modifiedPath.split("/").filter(segment => segment.length > 0); // Extract the first path part as the storeId (assumed app identifier) @@ -137,7 +142,7 @@ export const parseUdi = async ( const storeInfo = await dataStore.fetchCoinInfo(); rootHash = storeInfo.latestStore.metadata.rootHash.toString("hex"); - const redirect = `/chia.${storeId}.${rootHash}${appendPath}`; + const redirect = `/chia.${storeId}.${rootHash}${appendPath}${queryString ? '?' + queryString : ''}`; console.log("Redirecting to:", redirect); return res.redirect(302, redirect); } @@ -145,7 +150,7 @@ export const parseUdi = async ( // If chainName is missing, assume "chia" if (!chainName) { console.log("ChainName missing, defaulting to 'chia'."); - return res.redirect(302, `/chia.${pathSegment}${appendPath}`); + return res.redirect(302, `/chia.${pathSegment}${appendPath}${queryString ? '?' + queryString : ''}`); } // Validate the chainName From 49a3311a51a56433345afadd1db435ac1e9cea73 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Fri, 20 Sep 2024 09:13:48 -0400 Subject: [PATCH 2/2] chore(release): 0.0.1-alpha.37 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff83f46..f9f2032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.0.1-alpha.37](https://github.com/DIG-Network/dig-content-server/compare/v0.0.1-alpha.36...v0.0.1-alpha.37) (2024-09-20) + + +### Bug Fixes + +* store routes ([2e80979](https://github.com/DIG-Network/dig-content-server/commit/2e8097929e10f4eb4e705fb8777ec6dc429a7426)) + ### [0.0.1-alpha.36](https://github.com/DIG-Network/dig-content-server/compare/v0.0.1-alpha.35...v0.0.1-alpha.36) (2024-09-20) diff --git a/package-lock.json b/package-lock.json index 06ebd53..1c9c040 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dig-content-server", - "version": "0.0.1-alpha.36", + "version": "0.0.1-alpha.37", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dig-content-server", - "version": "0.0.1-alpha.36", + "version": "0.0.1-alpha.37", "license": "ISC", "dependencies": { "@dignetwork/dig-sdk": "^0.0.1-alpha.21", diff --git a/package.json b/package.json index a73b987..b2894f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dig-content-server", - "version": "0.0.1-alpha.36", + "version": "0.0.1-alpha.37", "description": "", "type": "commonjs", "main": "./dist/index.js",