(path: Path)
| 89 | } |
| 90 | |
| 91 | export function pathToUrl(path: Path): string { |
| 92 | if (path.slug.match(/^\d+$/)) { |
| 93 | return `https://myanimelist.net/${path.type}/${path.slug}`; |
| 94 | } |
| 95 | if (path.slug.startsWith('a:')) { |
| 96 | return `https://anilist.co/${path.type}/${path.slug.substring(2)}`; |
| 97 | } |
| 98 | if (path.slug.startsWith('k:')) { |
| 99 | return `https://kitsu.app/${path.type}/${path.slug.substring(2)}`; |
| 100 | } |
| 101 | if (path.slug.startsWith('s:')) { |
| 102 | return `https://simkl.com/${path.type}/${path.slug.substring(2)}`; |
| 103 | } |
| 104 | if (path.slug.startsWith('shi:')) { |
| 105 | return `https://shikimori.one/${path.type}s/${path.slug.substring(4)}`; |
| 106 | } |
| 107 | if (path.slug.startsWith('baka:')) { |
| 108 | return `https://mangabaka.org/${path.slug.substring(5)}`; |
| 109 | } |
| 110 | if (path.slug.startsWith('l:')) { |
| 111 | const match = path.slug.match(/^l:([^:]+)::([^:]+)$/); |
| 112 | if (match) { |
| 113 | return `local://${match[1]}/${path.type}/${decodeURIComponent(match[2])}`; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | throw new Error('Unknown Path Object'); |
| 118 | } |
no outgoing calls
no test coverage detected