Skip to content

Commit 6b4c89a

Browse files
authored
Ensure HTTPS is used for Speedrun.com Pagination (#1108)
Apparently their API returns HTTP links for pagination, which seems to get blocked nowadays. This forces the use of HTTPS for those links.
1 parent 66018ed commit 6b4c89a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

buildCore.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let profile = "debug";
66
let cargoFlags = "";
77
// Keep .github/workflows/ci.yml in sync with these flags, so wasm-opt works.
88
let rustFlags =
9-
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types,+tail-call";
9+
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types,+tail-call";
1010
let wasmBindgenFlags = "--encode-into always --target web --reference-types";
1111
let target = "wasm32-unknown-unknown";
1212
let targetFolder = target;
@@ -36,9 +36,9 @@ if (process.argv.some((v) => v === "--unstable")) {
3636
// Use the nightly toolchain, which enables some more optimizations.
3737
if (process.argv.some((v) => v === "--nightly")) {
3838
toolchain = "+nightly";
39-
cargoFlags +=
40-
" -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort";
41-
rustFlags += " -Z wasm-c-abi=spec";
39+
cargoFlags += " -Z build-std=std,panic_abort";
40+
rustFlags +=
41+
" -Z wasm-c-abi=spec -Z unstable-options -C panic=immediate-abort";
4242

4343
// FIXME: Apparently the multivalue ABI is broken again.
4444
// Caused by: https://github.com/rust-lang/rust/pull/135534
@@ -71,20 +71,20 @@ execSync(
7171
...process.env,
7272
RUSTFLAGS: rustFlags,
7373
},
74-
}
74+
},
7575
);
7676

7777
execSync(
7878
`wasm-bindgen ${wasmBindgenFlags} livesplit-core/target/${targetFolder}/${profile}/livesplit_core.wasm --out-dir src/livesplit-core`,
7979
{
8080
stdio: "inherit",
81-
}
81+
},
8282
);
8383

8484
fs.createReadStream(
85-
"livesplit-core/capi/bindings/wasm_bindgen/web/index.ts"
85+
"livesplit-core/capi/bindings/wasm_bindgen/web/index.ts",
8686
).pipe(fs.createWriteStream("src/livesplit-core/index.ts"));
8787

8888
fs.createReadStream(
89-
"livesplit-core/capi/bindings/wasm_bindgen/web/preload.ts"
89+
"livesplit-core/capi/bindings/wasm_bindgen/web/preload.ts",
9090
).pipe(fs.createWriteStream("src/livesplit-core/preload.ts"));

src/api/SpeedrunCom.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,9 @@ async function executePaginatedRequest<T>(uri: string): Promise<Page<T>> {
316316
if (pagination.links != null) {
317317
const nextLink = pagination.links.find((l: any) => l.rel === "next");
318318
if (nextLink != null) {
319-
const link = nextLink.uri as string;
320-
next = () => executePaginatedRequest<T>(link);
319+
const link = new URL(nextLink.uri as string);
320+
link.protocol = "https:"; // Ensure HTTPS, their API seems to return HTTP links.
321+
next = () => executePaginatedRequest<T>(link.toString());
321322
}
322323
}
323324
return new Page(data as T[], next);

0 commit comments

Comments
 (0)