(url, title)
| 62 | * noLowercase -> Dont lowercase everything |
| 63 | */ |
| 64 | export function searchSyntax(url, title) { |
| 65 | let resTitle = title.replace(/^\[l\]/i, '').trim(); |
| 66 | let options: option[] = []; |
| 67 | |
| 68 | const found = url.match(/{searchterm(\(.\))?(\[[^[\]]*\])?}/); |
| 69 | |
| 70 | if (!found) return url; |
| 71 | |
| 72 | const [res, space, tempOptions] = found; |
| 73 | |
| 74 | if (tempOptions) { |
| 75 | options = tempOptions.substring(1, tempOptions.length - 1).split(','); |
| 76 | } |
| 77 | |
| 78 | if (!options.includes('noLowercase')) { |
| 79 | resTitle = resTitle.toLowerCase(); |
| 80 | } |
| 81 | |
| 82 | if (options.includes('noSpecial')) { |
| 83 | resTitle = resTitle |
| 84 | .replace(/[^a-zA-Z\d ]/g, '') |
| 85 | .replace(/ +/g, ' ') |
| 86 | .trim(); |
| 87 | } else if (options.includes('specialReplace')) { |
| 88 | resTitle = resTitle |
| 89 | .replace(/[^a-zA-Z\d ]/g, ' ') |
| 90 | .replace(/ +/g, ' ') |
| 91 | .trim(); |
| 92 | } |
| 93 | |
| 94 | if (!options.includes('noEncode')) { |
| 95 | resTitle = encodeURIComponent(resTitle); |
| 96 | } else { |
| 97 | resTitle = resTitle.replace(/\//g, ' '); |
| 98 | } |
| 99 | |
| 100 | if (space) { |
| 101 | resTitle = resTitle.replace(/(%20| )/g, space[1]); |
| 102 | } |
| 103 | |
| 104 | return url.replace(res, resTitle); |
| 105 | } |
| 106 | |
| 107 | async function fillFromApi(combined, type, id) { |
| 108 | const mal = await getMalToKissApi(type, id); |
no outgoing calls
no test coverage detected