From fbd6d80b7d3f753c7883efc3acfb49e879fb0c94 Mon Sep 17 00:00:00 2001 From: MrOrz Date: Mon, 2 Sep 2024 14:57:43 +0800 Subject: [PATCH] fix: IA API actually requires form body instead of query strings. --- src/util/__tests__/archiveUrlsFromText.ts | 44 +++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/util/__tests__/archiveUrlsFromText.ts b/src/util/__tests__/archiveUrlsFromText.ts index 7378d33e..9c8b7942 100644 --- a/src/util/__tests__/archiveUrlsFromText.ts +++ b/src/util/__tests__/archiveUrlsFromText.ts @@ -78,8 +78,28 @@ describe('archiveUrlsFromText', () => { expect(mockedFetch.mock.calls).toMatchInlineSnapshot(` Array [ Array [ - "https://web.archive.org/save?url=https%3A%2F%2Fexample.com%2F&capture_screenshot=1&skip_first_archive=1&delay_wb_availability=1", + "https://web.archive.org/save", Object { + "body": FormData { + Symbol(state): Array [ + Object { + "name": "url", + "value": "https://example.com/", + }, + Object { + "name": "capture_screenshot", + "value": "1", + }, + Object { + "name": "skip_first_archive", + "value": "1", + }, + Object { + "name": "delay_wb_availability", + "value": "1", + }, + ], + }, "headers": Object { "Accept": "application/json", "Authorization": "LOW test-access-key:test-secret", @@ -88,8 +108,28 @@ describe('archiveUrlsFromText', () => { }, ], Array [ - "https://web.archive.org/save?url=https%3A%2F%2Fexample2.com%2F%3Ffoo%3Dbar&capture_screenshot=1&skip_first_archive=1&delay_wb_availability=1", + "https://web.archive.org/save", Object { + "body": FormData { + Symbol(state): Array [ + Object { + "name": "url", + "value": "https://example2.com/?foo=bar", + }, + Object { + "name": "capture_screenshot", + "value": "1", + }, + Object { + "name": "skip_first_archive", + "value": "1", + }, + Object { + "name": "delay_wb_availability", + "value": "1", + }, + ], + }, "headers": Object { "Accept": "application/json", "Authorization": "LOW test-access-key:test-secret",