forked from MapComplete/MapComplete
Refactoring: move all code files into a src directory
This commit is contained in:
parent
de99f56ca8
commit
e75d2789d2
389 changed files with 0 additions and 12 deletions
41
src/Logic/ImageProviders/GenericImageProvider.ts
Normal file
41
src/Logic/ImageProviders/GenericImageProvider.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import ImageProvider, { ProvidedImage } from "./ImageProvider"
|
||||
|
||||
export default class GenericImageProvider extends ImageProvider {
|
||||
public defaultKeyPrefixes: string[] = ["image"]
|
||||
|
||||
private readonly _valuePrefixBlacklist: string[]
|
||||
|
||||
public constructor(valuePrefixBlacklist: string[]) {
|
||||
super()
|
||||
this._valuePrefixBlacklist = valuePrefixBlacklist
|
||||
}
|
||||
|
||||
async ExtractUrls(key: string, value: string): Promise<Promise<ProvidedImage>[]> {
|
||||
if (this._valuePrefixBlacklist.some((prefix) => value.startsWith(prefix))) {
|
||||
return []
|
||||
}
|
||||
|
||||
try {
|
||||
new URL(value)
|
||||
} catch (_) {
|
||||
// Not a valid URL
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
Promise.resolve({
|
||||
key: key,
|
||||
url: value,
|
||||
provider: this,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
SourceIcon(backlinkSource?: string) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
public DownloadAttribution(url: string) {
|
||||
return undefined
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue