mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-02 21:22:00 +08:00
✨ Feature(custom): add thumbnail suffix functionality and related settings
ISSUES CLOSED: #539
This commit is contained in:
36
tests/thumbnail-url.test.ts
Normal file
36
tests/thumbnail-url.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { appendThumbnailSuffix } from '../src/renderer/manage/utils/thumbnailUrl'
|
||||
|
||||
describe('appendThumbnailSuffix', () => {
|
||||
it('keeps the original URL when the suffix is empty', () => {
|
||||
const url = 'https://example.com/image.png'
|
||||
|
||||
expect(appendThumbnailSuffix(url, '')).toBe(url)
|
||||
expect(appendThumbnailSuffix(url)).toBe(url)
|
||||
})
|
||||
|
||||
it('appends query-style suffixes to URLs without query strings', () => {
|
||||
expect(appendThumbnailSuffix('https://example.com/image.png', '?imageMogr2/thumbnail/200x200')).toBe(
|
||||
'https://example.com/image.png?imageMogr2/thumbnail/200x200',
|
||||
)
|
||||
})
|
||||
|
||||
it('converts query-style suffixes to additional parameters when the URL already has a query string', () => {
|
||||
expect(appendThumbnailSuffix('https://example.com/image.png?version=1', '?imageMogr2/thumbnail/200x200')).toBe(
|
||||
'https://example.com/image.png?version=1&imageMogr2/thumbnail/200x200',
|
||||
)
|
||||
})
|
||||
|
||||
it('normalizes ampersand-prefixed suffixes when the URL has no query string', () => {
|
||||
expect(appendThumbnailSuffix('https://example.com/image.png', '&x-oss-process=image/resize,w_200')).toBe(
|
||||
'https://example.com/image.png?x-oss-process=image/resize,w_200',
|
||||
)
|
||||
})
|
||||
|
||||
it('appends path-style suffixes unchanged', () => {
|
||||
expect(appendThumbnailSuffix('https://example.com/image.png', '/thumbnail/200x200')).toBe(
|
||||
'https://example.com/image.png/thumbnail/200x200',
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user