Skip to content

Commit 4cc7b20

Browse files
committed
fix: preserve URL ownership loading contract (#2146)
1 parent e820949 commit 4cc7b20

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

‎src/__tests__/eager-closure-budgets.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ export const HUB_BUDGETS: Readonly<Record<string, number>> = Object.freeze({
398398
// module records for the same code, with no new subtree behind any of them.
399399
// #2148 moves output-only CLI dependencies behind call-time imports and reduces the entry
400400
// closure by two modules.
401-
'src/cli.ts': 378,
401+
// #2146 splits one eagerly reached URL utility into its client and Metro owners.
402+
'src/cli.ts': 379,
402403
'src/platform-runtime.ts': 47,
403404
'src/core/command-descriptor/registry.ts': 71,
404405
'src/core/command-descriptor/platform-execution-entry.ts': 3,

‎src/client/base-url.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
export function normalizeBaseUrl(input: string): string {
22
let end = input.length;
3-
while (end > 0 && input.charCodeAt(end - 1) === 47) {
4-
end -= 1;
5-
}
3+
while (end > 0 && input.charCodeAt(end - 1) === 47) end -= 1;
64
return end === input.length ? input : input.slice(0, end);
75
}

‎src/metro/bundle-url.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { normalizeBaseUrl } from '../client/base-url.ts';
2-
32
export function buildBundleUrl(
43
baseUrl: string,
54
platform: 'ios' | 'android',
65
entryPath = 'index.bundle',
76
): string {
87
const url = new URL(`${normalizeBaseUrl(baseUrl)}/${entryPath}`);
9-
url.searchParams.set('platform', platform);
10-
url.searchParams.set('dev', 'true');
11-
url.searchParams.set('minify', 'false');
8+
const query = { platform, dev: 'true', minify: 'false' };
9+
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, value));
1210
return url.toString();
1311
}

0 commit comments

Comments
 (0)