Skip to content

Commit

Permalink
fix: fix name extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
kawarimidoll committed May 25, 2022
1 parent 0d11832 commit ab44146
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ sift({
}
return json({ message: "something went wrong." }, { status: 500 });
},
"/:slug": async (_, params = { slug: "" }) => {
const name = Array.isArray(params.slug) ? params.slug[0] : params.slug;
"/:slug": async (request) => {
const { pathname } = new URL(request.url);
// /aaa/bbb/ccc -> aaa
const name = pathname.slice(1).replace(/\/.*/, "");
console.log(name);

const item = await getItem(name);
Expand Down

0 comments on commit ab44146

Please sign in to comment.