feat: add support of .xml extension to gitPathFromId
This commit is contained in:
parent
5486a41198
commit
b7aee1740e
3 changed files with 6 additions and 3 deletions
|
@ -18,7 +18,7 @@ Defined in: legal/ids.ts:28
|
|||
|
||||
### extension
|
||||
|
||||
`".json"` | `".md"`
|
||||
`".json"` | `".md"` | `".xml"`
|
||||
|
||||
## Returns
|
||||
|
||||
|
|
|
@ -25,7 +25,10 @@ export function extractTypeFromId(id: string): IdType {
|
|||
return idMatch[2] as IdType
|
||||
}
|
||||
|
||||
export function gitPathFromId(id: string, extension: ".json" | ".md"): string {
|
||||
export function gitPathFromId(
|
||||
id: string,
|
||||
extension: ".json" | ".md" | ".xml",
|
||||
): string {
|
||||
const idMatch = id.match(idRegExp)
|
||||
if (idMatch === null) {
|
||||
throw new Error(`Unknown ID format: ${id}`)
|
||||
|
|
|
@ -93,7 +93,7 @@ export const load: PageLoad = async ({ params, url }) => {
|
|||
redirect(
|
||||
303,
|
||||
new URL(
|
||||
`dila/dole/src/branch/main/global/${gitPathFromId(params.id, ".json")}`,
|
||||
`dila/dole/src/branch/main/global/${gitPathFromId(params.id, ".xml")}`,
|
||||
forgejo.url,
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue