Skip to content

Commit

Permalink
fix: always exclude routeParams
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Nov 18, 2024
1 parent 3ba9093 commit 1466886
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions apps/renderer/src/lib/path-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ export type PathParams = {

export type ParseRegexpPathParamsOptions = {
excludeNames?: string[]
forceExcludeNames?: string[]
}
export const parseRegexpPathParams = (
regexpPath: string,
options?: ParseRegexpPathParamsOptions,
) => {
const { excludeNames = [] } = options || {}
const { excludeNames = [], forceExcludeNames = [] } = options || {}
const transformedPath = transformUriPath(regexpPath)
const { tokens } = parse(transformedPath)

Expand Down Expand Up @@ -151,7 +152,8 @@ export const parseRegexpPathParams = (
(item) =>
typeof item === "object" &&
"name" in item &&
(!excludeNames.includes(item.name) || !item.optional),
(!excludeNames.includes(item.name) || !item.optional) &&
!forceExcludeNames.includes(item.name),
) as PathParams[]
}
export const parseFullPathParams = (path: string, regexpPath: string) => {
Expand Down
3 changes: 2 additions & 1 deletion apps/renderer/src/modules/discover/DiscoverFeedForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ export const DiscoverFeedForm = ({
"lang",
"sort",
],
forceExcludeNames: routeParams ? ["routeParams"] : [],
}),
[route.path],
[route.path, routeParams],
)

const formPlaceholder = useMemo<Record<string, string>>(() => {
Expand Down

0 comments on commit 1466886

Please sign in to comment.