(url: string)
| 12 | import { Single as LocalSingle } from './Local/single'; |
| 13 | |
| 14 | export 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 | |
| 49 | export async function getRulesCacheKey( |
| 50 | url: string, |
no test coverage detected