@flrande/bak-extension 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.bak-e2e-build-stamp +1 -1
- package/dist/background.global.js +15 -1
- package/package.json +2 -2
- package/src/background.ts +19 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
2026-03-
|
|
1
|
+
2026-03-09T13:25:43.147Z
|
|
@@ -1048,13 +1048,14 @@
|
|
|
1048
1048
|
});
|
|
1049
1049
|
}
|
|
1050
1050
|
async function waitForTabUrl(tabId, expectedUrl, timeoutMs = 1e4) {
|
|
1051
|
+
const normalizedExpectedUrl = normalizeComparableTabUrl(expectedUrl);
|
|
1051
1052
|
const deadline = Date.now() + timeoutMs;
|
|
1052
1053
|
while (Date.now() < deadline) {
|
|
1053
1054
|
try {
|
|
1054
1055
|
const tab = await chrome.tabs.get(tabId);
|
|
1055
1056
|
const currentUrl = tab.url ?? "";
|
|
1056
1057
|
const pendingUrl = "pendingUrl" in tab && typeof tab.pendingUrl === "string" ? tab.pendingUrl : "";
|
|
1057
|
-
if (currentUrl ===
|
|
1058
|
+
if (normalizeComparableTabUrl(currentUrl) === normalizedExpectedUrl || normalizeComparableTabUrl(pendingUrl) === normalizedExpectedUrl) {
|
|
1058
1059
|
return;
|
|
1059
1060
|
}
|
|
1060
1061
|
} catch {
|
|
@@ -1063,6 +1064,19 @@
|
|
|
1063
1064
|
}
|
|
1064
1065
|
throw new Error(`tab url timeout: ${tabId} -> ${expectedUrl}`);
|
|
1065
1066
|
}
|
|
1067
|
+
function normalizeComparableTabUrl(url) {
|
|
1068
|
+
const raw = url.trim();
|
|
1069
|
+
if (!raw) {
|
|
1070
|
+
return raw;
|
|
1071
|
+
}
|
|
1072
|
+
try {
|
|
1073
|
+
const parsed = new URL(raw);
|
|
1074
|
+
parsed.hash = "";
|
|
1075
|
+
return parsed.href;
|
|
1076
|
+
} catch {
|
|
1077
|
+
return raw;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1066
1080
|
async function finalizeOpenedWorkspaceTab(opened, expectedUrl) {
|
|
1067
1081
|
if (expectedUrl && expectedUrl !== "about:blank") {
|
|
1068
1082
|
await waitForTabUrl(opened.tab.id, expectedUrl).catch(() => void 0);
|
package/package.json
CHANGED
package/src/background.ts
CHANGED
|
@@ -372,13 +372,17 @@ async function waitForTabComplete(tabId: number, timeoutMs = DEFAULT_TAB_LOAD_TI
|
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
async function waitForTabUrl(tabId: number, expectedUrl: string, timeoutMs = 10_000): Promise<void> {
|
|
375
|
+
const normalizedExpectedUrl = normalizeComparableTabUrl(expectedUrl);
|
|
375
376
|
const deadline = Date.now() + timeoutMs;
|
|
376
377
|
while (Date.now() < deadline) {
|
|
377
378
|
try {
|
|
378
379
|
const tab = await chrome.tabs.get(tabId);
|
|
379
380
|
const currentUrl = tab.url ?? '';
|
|
380
381
|
const pendingUrl = 'pendingUrl' in tab && typeof tab.pendingUrl === 'string' ? tab.pendingUrl : '';
|
|
381
|
-
if (
|
|
382
|
+
if (
|
|
383
|
+
normalizeComparableTabUrl(currentUrl) === normalizedExpectedUrl ||
|
|
384
|
+
normalizeComparableTabUrl(pendingUrl) === normalizedExpectedUrl
|
|
385
|
+
) {
|
|
382
386
|
return;
|
|
383
387
|
}
|
|
384
388
|
} catch {
|
|
@@ -390,6 +394,20 @@ async function waitForTabUrl(tabId: number, expectedUrl: string, timeoutMs = 10_
|
|
|
390
394
|
throw new Error(`tab url timeout: ${tabId} -> ${expectedUrl}`);
|
|
391
395
|
}
|
|
392
396
|
|
|
397
|
+
function normalizeComparableTabUrl(url: string): string {
|
|
398
|
+
const raw = url.trim();
|
|
399
|
+
if (!raw) {
|
|
400
|
+
return raw;
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const parsed = new URL(raw);
|
|
404
|
+
parsed.hash = '';
|
|
405
|
+
return parsed.href;
|
|
406
|
+
} catch {
|
|
407
|
+
return raw;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
393
411
|
async function finalizeOpenedWorkspaceTab(
|
|
394
412
|
opened: Awaited<ReturnType<WorkspaceManager['openTab']>>,
|
|
395
413
|
expectedUrl?: string
|