summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context
diff options
context:
space:
mode:
authorshirukai <[email protected]>2026-01-21 18:35:23 +0800
committerGitHub <[email protected]>2026-01-21 04:35:23 -0600
commitcf6ad4c40789beef8a0f2a07f12964fd5fdd2b09 (patch)
treef7a3c3126ad5017112315ddfa0fcb85b0cd072ec /packages/app/src/context
parentd6caaee8169ff1abd7012cc1d036f2621703a757 (diff)
downloadopencode-cf6ad4c40789beef8a0f2a07f12964fd5fdd2b09.tar.gz
opencode-cf6ad4c40789beef8a0f2a07f12964fd5fdd2b09.zip
fix: handle special characters in paths and git snapshot reading logic(#9804) (#9807)
Diffstat (limited to 'packages/app/src/context')
-rw-r--r--packages/app/src/context/file.tsx18
1 files changed, 16 insertions, 2 deletions
diff --git a/packages/app/src/context/file.tsx b/packages/app/src/context/file.tsx
index 5ea499387..d7630509a 100644
--- a/packages/app/src/context/file.tsx
+++ b/packages/app/src/context/file.tsx
@@ -195,7 +195,20 @@ export const { use: useFile, provider: FileProvider } = createSimpleContext({
const root = directory()
const prefix = root.endsWith("/") ? root : root + "/"
- let path = stripQueryAndHash(stripFileProtocol(input))
+ let path = input
+
+ // Only strip protocol and decode if it's a file URI
+ if (path.startsWith("file://")) {
+ const raw = stripQueryAndHash(stripFileProtocol(path))
+ try {
+ // Attempt to treat as a standard URI
+ path = decodeURIComponent(raw)
+ } catch {
+ // Fallback for legacy paths that might contain invalid URI sequences (e.g. "100%")
+ // In this case, we treat the path as raw, but still strip the protocol
+ path = raw
+ }
+ }
if (path.startsWith(prefix)) {
path = path.slice(prefix.length)
@@ -218,7 +231,8 @@ export const { use: useFile, provider: FileProvider } = createSimpleContext({
function tab(input: string) {
const path = normalize(input)
- return `file://${path}`
+ const encoded = path.split("/").map(encodeURIComponent).join("/")
+ return `file://${encoded}`
}
function pathFromTab(tabValue: string) {