Skip to content

Commit

Permalink
Merge pull request #33 from DIG-Network/release/v0.0.1-alpha.37
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.37
  • Loading branch information
MichaelTaylor3D authored Sep 20, 2024
2 parents 426f991 + 49a3311 commit ebc920b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
17 changes: 11 additions & 6 deletions src/middleware/parseUdi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function removeDuplicatePathPart(path: string): string {
}

const modifiedPath = '/' + parts.join('/');

console.log('Original path:', path);
console.log('Modified path:', modifiedPath);

Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -137,15 +142,15 @@ 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);
}

// 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
Expand Down

0 comments on commit ebc920b

Please sign in to comment.