Skip to content

Commit 1e41d41

Browse files
committed
パスに # が含まれていると壊れるので URL エンコードする
スペースとかもバグのもとなのでパスの要素ごとに URL エンコードするようにした、Windows では問題なく動いた
1 parent 4b2ec9d commit 1e41d41

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/miraktest-local/components/FileSelector.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,16 @@ export const FileSelector: React.VFC<{
126126
if (!path) {
127127
return
128128
}
129-
setFilePath(
130-
// Windows なら file:///C:\path\to\file.m2ts、Linux / Mac なら file:///path/to/file.m2ts になるように加工する
131-
"file:///" + path.at(0) === "/" ? path.slice(1) : path
132-
)
129+
// Windows なら file:///C:\path\to\file.m2ts、Linux / Mac なら file:///path/to/file.m2ts になるように加工する。パスの要素それぞれに対してパーセントエンコードをする
130+
const url =
131+
"file:///" +
132+
path
133+
.replaceAll(/\\/g, "/")
134+
.split("/")
135+
.filter((p) => p !== "")
136+
.map((p) => encodeURIComponent(p))
137+
.join("/")
138+
setFilePath(url)
133139
}}
134140
>
135141
<File className="pointer-events-none" size="1.75rem" />

0 commit comments

Comments
 (0)