Add storage_use_date_path for flat vs date-key storage layout and emit basename-only public URLs when hide-folder is enabled. Block image paths on the site host when domain separation is active so only the image host serves files. Update settings UI, i18n, tests, and deployment docs.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
isBareImageFilename,
|
|
isHiddenImageDatePath,
|
|
toPublicImagePath
|
|
} from './image-public-path'
|
|
|
|
describe('toPublicImagePath', () => {
|
|
it('returns key unchanged when hideFolder is false', () => {
|
|
expect(toPublicImagePath('images/2026/08/a.webp', false)).toBe('images/2026/08/a.webp')
|
|
expect(toPublicImagePath('images/a.webp', false)).toBe('images/a.webp')
|
|
})
|
|
|
|
it('returns basename when hideFolder is true', () => {
|
|
expect(toPublicImagePath('images/2026/08/a.webp', true)).toBe('a.webp')
|
|
expect(toPublicImagePath('blog/2026/08/a.webp', true)).toBe('a.webp')
|
|
expect(toPublicImagePath('images/a.webp', true)).toBe('a.webp')
|
|
})
|
|
})
|
|
|
|
describe('isHiddenImageDatePath', () => {
|
|
it('accepts YYYY/MM/file paths', () => {
|
|
expect(isHiddenImageDatePath('2026/08/demo.webp')).toBe(true)
|
|
})
|
|
|
|
it('rejects folder-prefixed paths', () => {
|
|
expect(isHiddenImageDatePath('images/2026/08/demo.webp')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('isBareImageFilename', () => {
|
|
it('accepts bare filenames', () => {
|
|
expect(isBareImageFilename('demo.webp')).toBe(true)
|
|
})
|
|
|
|
it('rejects paths with directories', () => {
|
|
expect(isBareImageFilename('2026/08/demo.webp')).toBe(false)
|
|
expect(isBareImageFilename('images/demo.webp')).toBe(false)
|
|
})
|
|
})
|