MCPcopy Create free account
hub / github.com/MALSync/MALSync / pathToUrl

Function pathToUrl

src/utils/slugs.ts:91–118  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

89}
90
91export 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}

Callers 2

slug.test.tsFile · 0.90
setLinksFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected