fix: deleted image wrongfully caching
This commit is contained in:
1 parent
b3793d5dbb
commit
ff0854f331
19 files changed
+201
-87
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
const UPLOADED_IMAGES_PATH = '/static/uploadedImages/'
|
||||
|
||||
export const mediaRevision = ref(0)
|
||||
|
||||
export function bumpMediaRevision() {
|
||||
mediaRevision.value += 1
|
||||
}
|
||||
|
||||
export function withMediaRevision(src: string | undefined, revision = mediaRevision.value) {
|
||||
if (!src || revision === 0 || !src.includes(UPLOADED_IMAGES_PATH)) {
|
||||
return src
|
||||
}
|
||||
const hashAt = src.indexOf('#')
|
||||
const base = hashAt === -1 ? src : src.slice(0, hashAt)
|
||||
const hash = hashAt === -1 ? '' : src.slice(hashAt)
|
||||
const separator = base.includes('?') ? '&' : '?'
|
||||
return `${base}${separator}rev=${revision}${hash}`
|
||||
}
|
||||
Reference in new issue
Block a user