feat: add support of .xml extension to gitPathFromId

This commit is contained in:
Emmanuel 2025-06-28 08:55:20 +02:00
parent 5486a41198
commit b7aee1740e
3 changed files with 6 additions and 3 deletions

View file

@ -18,7 +18,7 @@ Defined in: legal/ids.ts:28
### extension
`".json"` | `".md"`
`".json"` | `".md"` | `".xml"`
## Returns

View file

@ -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}`)

View file

@ -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,
),
)