Files
FileHost/server/utils/image-public-path.test.ts
T
O96u d8c1303c32
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
release: v1.1.3 — dual-domain separation and URL options
Add admin/image domain separation with host isolation middleware,
optional hide-folder public URLs, GitHub release update check, and
Lucky/Nginx deployment docs. Switch license to GPL-3.0-only.
2026-08-27 12:13:58 +08:00

24 lines
855 B
TypeScript

import { describe, expect, it } from 'vitest'
import { 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')
})
it('strips the first path segment when hideFolder is true', () => {
expect(toPublicImagePath('images/2026/08/a.webp', true)).toBe('2026/08/a.webp')
expect(toPublicImagePath('blog/2026/08/a.webp', true)).toBe('2026/08/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)
})
})