mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-25 13:04:09 -03:00
feat: support reverse-proxy URL subpaths (llama-swap, SwarmUI) (#1122)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { getLmBasePath, lmApiUrl } from '@/utils/basePath'
|
||||
|
||||
const originalPathname = window.location.pathname
|
||||
|
||||
function setPathname(pathname: string) {
|
||||
window.history.replaceState(null, '', pathname)
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
setPathname(originalPathname)
|
||||
})
|
||||
|
||||
describe('getLmBasePath', () => {
|
||||
it('returns an empty string when ComfyUI is served at the root', () => {
|
||||
setPathname('/')
|
||||
|
||||
expect(getLmBasePath()).toBe('')
|
||||
})
|
||||
|
||||
it('strips the trailing slash from a subpath prefix', () => {
|
||||
setPathname('/comfyui/')
|
||||
|
||||
expect(getLmBasePath()).toBe('/comfyui')
|
||||
})
|
||||
|
||||
it('keeps a prefix without a trailing slash as-is', () => {
|
||||
setPathname('/ComfyBackendDirect')
|
||||
|
||||
expect(getLmBasePath()).toBe('/ComfyBackendDirect')
|
||||
})
|
||||
})
|
||||
|
||||
describe('lmApiUrl', () => {
|
||||
it('leaves root-absolute paths unchanged at the root', () => {
|
||||
setPathname('/')
|
||||
|
||||
expect(lmApiUrl('/api/lm/loras/list')).toBe('/api/lm/loras/list')
|
||||
})
|
||||
|
||||
it('prepends the subpath prefix to root-absolute paths', () => {
|
||||
setPathname('/comfyui/')
|
||||
|
||||
expect(lmApiUrl('/api/lm/loras/list')).toBe('/comfyui/api/lm/loras/list')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user