MCPcopy Index your code
hub / github.com/MALSync/MALSync / getSingle

Function getSingle

src/_provider/singleFactory.ts:14–47  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

12import { Single as LocalSingle } from './Local/single';
13
14export function getSingle(url: string) {
15 if (/^local:\/\//i.test(url)) {
16 return new LocalSingle(url);
17 }
18
19 const slug = urlToSlug(url);
20 if (!slug.path) {
21 throw new Error(`URL not supported: ${url}`);
22 }
23
24 const syncMode = helper.getSyncMode(slug.path.type);
25 if (syncMode === 'MAL') {
26 return new MalSingle(url);
27 }
28 if (syncMode === 'MALAPI') {
29 return new MalApiSingle(url);
30 }
31 if (syncMode === 'ANILIST') {
32 return new AnilistSingle(url);
33 }
34 if (syncMode === 'KITSU') {
35 return new KitsuSingle(url);
36 }
37 if (syncMode === 'MANGABAKA') {
38 return new MangaBakaSingle(url);
39 }
40 if (syncMode === 'SIMKL') {
41 return new SimklSingle(url);
42 }
43 if (syncMode === 'SHIKI') {
44 return new ShikiSingle(url);
45 }
46 throw 'Unknown sync mode';
47}
48
49export async function getRulesCacheKey(
50 url: string,

Callers 2

handlePageMethod · 0.90
getRulesCacheKeyFunction · 0.70

Calls 1

urlToSlugFunction · 0.90

Tested by

no test coverage detected