Browse Source

URL encode better

e.g. fixes the reading of a file with a hash in the name
Manav Rathi 1 năm trước cách đây
mục cha
commit
b967d4bbea
2 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 3 0
      desktop/src/main/stream.ts
  2. 4 2
      web/apps/photos/src/utils/native-stream.ts

+ 3 - 0
desktop/src/main/stream.ts

@@ -50,6 +50,9 @@ export const registerStreamProtocol = () => {
         const path = decodeURIComponent(pathname);
         // `hash` begins with a "#", slice that off.
         const hashPath = decodeURIComponent(hash.slice(1));
+        log.debug(
+            () => `[stream] ${host} ${path}${hashPath ? "::" + hashPath : ""}`,
+        );
         switch (host) {
             case "read":
                 return handleRead(path);

+ 4 - 2
web/apps/photos/src/utils/native-stream.ts

@@ -39,10 +39,12 @@ export const readStream = async (
 ): Promise<{ response: Response; size: number; lastModifiedMs: number }> => {
     let url: URL;
     if (typeof pathOrZipItem == "string") {
-        url = new URL(`stream://read${pathOrZipItem}`);
+        url = new URL("stream://read");
+        url.pathname = pathOrZipItem
     } else {
         const [zipPath, entryName] = pathOrZipItem;
-        url = new URL(`stream://read-zip${zipPath}`);
+        url = new URL("stream://read-zip");
+        url.pathname = zipPath;
         url.hash = entryName;
     }