Skip to content

Commit

Permalink
Add support for chinese file names
Browse files Browse the repository at this point in the history
Resolves #4
  • Loading branch information
Elias Sundqvist committed Aug 26, 2021
1 parent 05e25b6 commit b5329d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions defineLocalIframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ export default ({ vault, resourceUrls }: { vault: Vault; resourceUrls: Map<strin
try {
const folder = await hypothesisFolder;
const pathName = normalizePath(url.pathname);
const file = folder.file(pathName) || folder.file(`${pathName}.html`);
const file =
folder.file(pathName) ||
folder.file(`${pathName}.html`) ||
folder.file(`${decodeURI(pathName)}`) ||
folder.file(`${decodeURI(pathName)}.html`);
buf = await file.async('arraybuffer');
return new Response(buf, {
status: 200,
Expand All @@ -203,7 +207,11 @@ export default ({ vault, resourceUrls }: { vault: Vault; resourceUrls: Map<strin
}
if (url.protocol == 'vault:') {
try {
buf = await readFromVaultPath(normalizePath(url.pathname));
try {
buf = await readFromVaultPath(normalizePath(url.pathname));
} catch (e) {
buf = await readFromVaultPath(normalizePath(decodeURI(url.pathname)));
}
return new Response(buf, {
status: 200,
statusText: 'ok'
Expand Down

0 comments on commit b5329d9

Please sign in to comment.