mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 06:44:21 +00:00
🔧 Accept urls without trailing slashes
This commit is contained in:
parent
ad1f12393c
commit
fd81459b01
2 changed files with 3 additions and 3 deletions
|
@ -55,7 +55,7 @@ export function ViewSetRouter<Resource extends DjangoResource>({viewSet, unselec
|
|||
selection = viewSet.resources?.find(res => res.value[pkKey] === pk)
|
||||
if(!selection) {
|
||||
return (
|
||||
<ErrorBox error={new Error(`Resource not found: ${pk}`)}/>
|
||||
<ErrorBox error={new Error(`Resource "${pk}" of type "${pathSegment}" not found`)}/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ function parsePathSegment({path, parsed, regex, key, next}: ParsePathSegmentConf
|
|||
|
||||
// If the match fails, it means the matching is over
|
||||
if(!match || !match.groups) {
|
||||
parsed.valid = path === "/"
|
||||
parsed.valid = path === "" || path === "/"
|
||||
return parsed
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ function parsePathSegment({path, parsed, regex, key, next}: ParsePathSegmentConf
|
|||
parsed.count += 1
|
||||
|
||||
const results = next.map((func) => {
|
||||
return func(rest, parsed)
|
||||
return func(rest ?? "", parsed)
|
||||
}).reduce((a, b) => {
|
||||
return {...a, ...b}
|
||||
}, {})
|
||||
|
|
Loading…
Reference in a new issue