mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
The server took a file named only .html for a page, which the desktop shows in the file panel, so tabs.open failed for want of a tab. A workspace address whose scheme or session ID was not in lower case named nothing, though the prefix it is compared with is written in lower case.
23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
import { expect, test } from "bun:test"
|
|
import { previewPath, remotePath, workspacePrefix } from "../src/preview-path.js"
|
|
|
|
test("a workspace address names its session in any case", () => {
|
|
const prefix = workspacePrefix("ses_AbC123")
|
|
|
|
for (const address of ["workspace://ses_abc123/site/page.html", "workspace://ses_AbC123/site/page.html", "WORKSPACE://SES_ABC123/site/page.html"])
|
|
expect(remotePath(address, prefix)).toBe("site/page.html")
|
|
// Another session's address names nothing here, and the path keeps its own case.
|
|
expect(remotePath("workspace://ses_other/site/page.html", prefix)).toBeUndefined()
|
|
expect(remotePath("workspace://ses_abc123/Site/Page.html", prefix)).toBe("Site/Page.html")
|
|
})
|
|
|
|
test("the disk owner, not the desktop OS, decides which relative names are valid", () => {
|
|
for (const path of ["src/aux.html", "icons/CON.svg", "12:00.png", "trailing."]) {
|
|
expect(previewPath(path, false)).toBe(true)
|
|
expect(previewPath(path, true)).toBe(false)
|
|
}
|
|
for (const path of ["a/../x", "C:/foo", "/a", "a//b", "a\\b", "a\0b"]) {
|
|
expect(previewPath(path, false)).toBe(false)
|
|
expect(previewPath(path, true)).toBe(false)
|
|
}
|
|
})
|