Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions apps/nuxt/src/tools/marked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ export class Marked {
}

public static isLocalLink(token: Tokens.Link): boolean {
if (URL.canParse(token.href)) {
if (!token.href) {
return false
}

const url = this.getUrl(token)

if (url) {
const config = useRuntimeConfig()
const url = new URL(token.href)

return (
[config.public.siteUrl, 'https://preprod.mission-transition-ecologique.incubateur.net', 'http://localhost:4242'].includes(
Expand All @@ -45,4 +50,19 @@ export class Marked {

return token.href.startsWith('/')
}

private static getUrl(token: Tokens.Link) {
let url: URL | undefined
if ('canParse' in URL && URL.canParse(token.href)) {
url = new URL(token.href)
} else {
try {
url = new URL(token.href)
} catch (e) {
url = undefined
}
}

return url
}
}
Loading