Skip to content

Commit

Permalink
Fix segment being encoded.
Browse files Browse the repository at this point in the history
  • Loading branch information
oBusk committed Nov 18, 2022
1 parent 4fb396e commit b76ddb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/[...parts]/page.tsx
Expand Up @@ -5,6 +5,7 @@ import { ViewType } from "react-diff-view";
import bundlephobia from "^/lib/api/bundlephobia";
import packagephobia from "^/lib/api/packagephobia";
import TIMED_OUT from "^/lib/api/TimedOut";
import decodePartts from "^/lib/decodeParts";
import { DEFAULT_DIFF_FILES_GLOB } from "^/lib/default-diff-files";
import destination from "^/lib/destination";
import doDiff, { DiffError } from "^/lib/diff";
Expand All @@ -29,7 +30,7 @@ const DiffPage = async ({
const headersList = headers();
const { diffFiles, ...optionsQuery } = searchParams;

const specsOrVersions = splitParts(parts);
const specsOrVersions = splitParts(decodePartts(parts));
const { redirect: redirectTarget, canonicalSpecs } = await destination(
specsOrVersions,
);
Expand Down
8 changes: 8 additions & 0 deletions src/lib/decodeParts.ts
@@ -0,0 +1,8 @@
const decodePartts = (parts: string | string[] | undefined) =>
parts == null
? parts
: Array.isArray(parts)
? parts.map(decodeURIComponent)
: decodeURIComponent(parts);

export default decodePartts;

0 comments on commit b76ddb0

Please sign in to comment.