widthdraw and deposit
This commit is contained in:
+10
-5
@@ -10,12 +10,17 @@ export interface ProductFile {
|
||||
|
||||
export function getFileUrl(file?: ProductFile | null): string | null {
|
||||
if (!file) return null
|
||||
if (file.full_src) return file.full_src
|
||||
if (file.url) return file.url
|
||||
if (!file.src) return null
|
||||
if (/^https?:\/\//i.test(file.src)) return file.src
|
||||
|
||||
for (const value of [file.full_src, file.url, file.src]) {
|
||||
if (!value) continue
|
||||
if (/^https?:\/\//i.test(value)) return value
|
||||
}
|
||||
|
||||
const relative = file.src || file.full_src
|
||||
if (!relative) return null
|
||||
|
||||
const base = baseURL.replace(/\/$/, '')
|
||||
const path = file.src.replace(/^\//, '')
|
||||
const path = String(relative).replace(/^\//, '')
|
||||
return `${base}/${path}`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user