You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
663 B
26 lines
663 B
|
2 years ago
|
'use strict'
|
||
|
|
|
||
|
|
import RequestClient from './RequestClient.js'
|
||
|
|
|
||
|
|
const getName = (id) => {
|
||
|
|
return id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ')
|
||
|
|
}
|
||
|
|
|
||
|
|
export default class SearchProvider extends RequestClient {
|
||
|
|
constructor (uppy, opts) {
|
||
|
|
super(uppy, opts)
|
||
|
|
this.provider = opts.provider
|
||
|
|
this.id = this.provider
|
||
|
|
this.name = this.opts.name || getName(this.id)
|
||
|
|
this.pluginId = this.opts.pluginId
|
||
|
|
}
|
||
|
|
|
||
|
|
fileUrl (id) {
|
||
|
|
return `${this.hostname}/search/${this.id}/get/${id}`
|
||
|
|
}
|
||
|
|
|
||
|
|
search (text, queries) {
|
||
|
|
return this.get(`search/${this.id}/list?q=${encodeURIComponent(text)}${queries ? `&${queries}` : ''}`)
|
||
|
|
}
|
||
|
|
}
|