redirect-map-plan 0.1.0 → 0.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 (28 November 2026)
4
+
5
+ - **Browser interface:** `npx redirect-map-plan ui` starts a local page (127.0.0.1 only) where you paste or drop the old URLs, pick the platforms (or let it suggest one, with the evidence), add the optional files, watch the plan being made, cancel it, work through every old URL by outcome, download the files and save them to a folder. Same protections as redirect-map-check's interface: a private token, host and origin checks, a strict content security policy, no local path the page names is ever read, a dropped sitemap index can only reach files dropped with it, and the temp folder never shows in what the page displays or hands over. Flags fill in the form; `--port` and `--no-open`.
6
+ - `buildPlan` takes `onPhase`, `onProgress`, `onPage`, `signal` and `confineTo`; `detectSource` takes `signal` and `confineTo`. `writePlan` takes `commandDir`.
7
+ - Needs redirect-map-check 0.2.1, which promises the `signal` and `confineTo` options this relies on.
8
+
3
9
  ## 0.1.0 (27 November 2026)
4
10
 
5
11
  - First version. From Webflow, WordPress (with WooCommerce), Shopify, Wix or Other to Shopify, Webflow or custom code.
package/README.md CHANGED
@@ -6,6 +6,12 @@ Plan a website migration's redirect map **before** the move. Give it the old sit
6
6
  npx redirect-map-plan --sitemap https://www.example.com/sitemap.xml --from webflow --to shopify
7
7
  ```
8
8
 
9
+ Or in your browser:
10
+
11
+ ```bash
12
+ npx redirect-map-plan ui
13
+ ```
14
+
9
15
  Free and open source (MIT), from [ITCrowd](https://itcrowd.work). It runs on your computer: nothing is uploaded anywhere. Node.js 22 or newer; no third-party dependencies (it uses redirect-map-check, our own package, to read sitemaps and fetch pages).
10
16
 
11
17
  ## Why we built it
@@ -28,7 +34,7 @@ Every platform has its own URL rules. Shopify puts pages under `/pages/` and blo
28
34
  |---|---|
29
35
  | Webflow, WordPress (with or without WooCommerce), Shopify, Wix, Other (URL patterns only) | Shopify, Webflow, custom code (Next.js, Astro, any host) |
30
36
 
31
- Any source works with any target. WordPress and Wix as targets, multilingual sites (Webflow Localization, Shopify Markets, WPML) and a browser interface come later. With language prefixes in the URLs (`/fr/…`), the plan says so and treats them as ordinary paths.
37
+ Any source works with any target. WordPress and Wix as targets and multilingual sites (Webflow Localization, Shopify Markets, WPML) come later. With language prefixes in the URLs (`/fr/…`), the plan says so and treats them as ordinary paths.
32
38
 
33
39
  If you leave out `--from`, the planner reads the URLs, tells you which platform they look like and why (for example "12 URLs under /products/"), and stops. A wrong source platform makes a wrong plan, so it waits for you to say.
34
40
 
@@ -104,6 +110,9 @@ Fetching (sitemaps, --titles)
104
110
 
105
111
  Output
106
112
  --out <dir> --limit <n> --no-color -q -h -v
113
+
114
+ Browser interface (redirect-map-plan ui)
115
+ --port <n> --no-open (any flag above fills in the form)
107
116
  ```
108
117
 
109
118
  **Old redirects.** Your old platform probably has redirects already (from earlier renames). Pass its export with `--old-redirects`: each old source gets a row pointing straight at the final new address. An old redirect from a page that's still live is ignored and named (it never fired: the page wins), and so are redirects that loop. An old redirect whose target matches a listed old URL only when upper and lower case are ignored (`/case → /About`, with `/about` in your list) is planned for the address as written and named in "Check these": whether the old site served one page at both, we can't tell. A Webflow export holds its old paths escaped (`/old%-page`), so with `--from webflow` they're read back as plain URLs; its pattern rows (`/blog/(.*)`) can't be carried over one URL at a time, so they're named instead: add the URLs they caught to `--urls` to plan them.
@@ -121,6 +130,24 @@ old,new
121
130
 
122
131
  A row where both values end in `/` renames a prefix. Where the target sets that part of the address itself (Shopify posts always go under `/blogs/{blog handle}/`), the plan says the rename can't apply and points to the option that can. Pinned rows still go through the target's checks, so a pin from a query-string URL such as `/?p=123` only gives a row on custom code: Shopify and Webflow can't take one.
123
132
 
133
+ ## In your browser
134
+
135
+ ```bash
136
+ npx redirect-map-plan ui
137
+ ```
138
+
139
+ This starts a page on your computer (only on `127.0.0.1`) and opens it. In the page you:
140
+
141
+ - paste the old sitemap's address, or drop a saved sitemap or a list of URLs;
142
+ - pick From and To. Not sure where the old site runs? Choose "Not sure, suggest one": the page shows which platform the URLs look like, and why, and waits for you to pick, as the command line does;
143
+ - optionally drop the old platform's redirect export and a rules file, and tick "Read each old page's title" for `old-pages.json`.
144
+
145
+ While it runs you see each step, and with titles each page as it's read; Cancel stops it. Then you get the counts, the settings to make on the new platform, "Check these", every old URL with a filter by outcome, the files to download (`plan.html` opens in a new tab), "Save to folder" (`./redirect-plan`, or `--out`), and the redirect-map-check command to run next.
146
+
147
+ Flags fill in the form: `npx redirect-map-plan ui --sitemap old-sitemap.xml --from webflow --to shopify`. A local file named on the command line stays on your side; the page only learns its name. `--port` picks the port (default 47471; redirect-map-check's interface uses 47470, so both can run at once) and `--no-open` just prints the address.
148
+
149
+ The page is as careful as redirect-map-check's: it only answers on `127.0.0.1` with the private token from the address printed in the terminal, refuses requests from other sites, never reads a file on your computer that the page names (only files you drop, or name on the command line, and a dropped sitemap index can only reach files dropped with it), and keeps its temp folder out of everything it shows or hands over. Files you drop go to a temp folder that's removed after the plan.
150
+
124
151
  ## Then check it
125
152
 
126
153
  The plan is half the job. Import the redirect file on the new platform's staging site, then:
@@ -184,7 +211,14 @@ await writePlan(plan, 'redirect-plan');
184
211
  for (const r of Object.values(PLATFORMS.webflow.rules)) console.log(r.id, r.status, r.source.url);
185
212
  ```
186
213
 
187
- `buildPlan` takes the same options as the command line, in camelCase (`sitemaps`, `urlLists`, `oldRedirects`, `rulesFile`, `from`, `to`, `blogHandle`, `postsCollection`, `titles`, `limit`, …) and returns the plan that `plan.json` holds. `writePlan(plan, folder)` writes the files and returns their paths.
214
+ `buildPlan` takes the same options as the command line, in camelCase (`sitemaps`, `urlLists`, `oldRedirects`, `rulesFile`, `from`, `to`, `blogHandle`, `postsCollection`, `titles`, `limit`, …) and returns the plan that `plan.json` holds. For an interface it also takes:
215
+
216
+ - `onPhase(name, detail)`: called at each step: `read`, `place` (`detail.urls`), `old-redirects`, `titles` (`detail.pages`);
217
+ - `onProgress(done, total)` and `onPage({ url, title, status })` while titles are read;
218
+ - `signal`, an AbortSignal: once it fires, the plan stops with an error whose `code` is `ECANCELLED`;
219
+ - `confineTo`, a folder: a local sitemap index inside it may only point at local files inside it (for files someone dropped into a folder of yours).
220
+
221
+ `writePlan(plan, folder, { commandDir })` writes the files and returns their paths. `commandDir` is the folder the printed redirect-map-check command names for `redirect-map.csv` (default: the folder written to).
188
222
 
189
223
  ## Development
190
224
 
@@ -18,6 +18,7 @@ address on the new platform, which keep it with one setting, and which must chan
18
18
 
19
19
  Usage
20
20
  npx redirect-map-plan --sitemap <url|file> --from <platform> --to <platform> [options]
21
+ npx redirect-map-plan ui [options] Open the browser interface (local only)
21
22
 
22
23
  Old URLs (at least one)
23
24
  --sitemap <url|file> Old sitemap or sitemap index (repeatable; .xml or .xml.gz).
@@ -54,6 +55,14 @@ Output
54
55
  -q, --quiet Print nothing except errors.
55
56
  -h, --help This help. -v, --version The version.
56
57
 
58
+ Browser interface (redirect-map-plan ui)
59
+ Starts a page on this computer (127.0.0.1 only) where you pick the files and the
60
+ platforms, watch the plan being made and download it. Any flag above fills in the
61
+ form (--sitemap, --urls, --old-redirects, --rules, --from, --to, …). Extra flags:
62
+ --port <n> Port to listen on (default 47471, or a free one if that's taken).
63
+ --no-open Don't open the browser; just print the address.
64
+ --out <dir> Where "Save to folder" writes (default ./redirect-plan).
65
+
57
66
  Docs: ${DOCS_URL}`;
58
67
 
59
68
  const fail = (message, code = 2) => {
@@ -62,11 +71,15 @@ const fail = (message, code = 2) => {
62
71
  };
63
72
 
64
73
  let parsed;
74
+ const subcommand = process.argv[2] === 'ui' ? 'ui' : null;
65
75
  try {
66
76
  parsed = parseArgs({
77
+ args: process.argv.slice(subcommand ? 3 : 2),
67
78
  allowPositionals: false,
68
79
  tokens: true,
69
80
  options: {
81
+ port: { type: 'string' },
82
+ 'no-open': { type: 'boolean' },
70
83
  sitemap: { type: 'string', multiple: true },
71
84
  urls: { type: 'string', multiple: true },
72
85
  'old-redirects': { type: 'string' },
@@ -131,9 +144,67 @@ for (const [flag, values] of [['sitemap', a.sitemap], ['urls', a.urls], ['old-re
131
144
  }
132
145
  }
133
146
 
134
- if (!a.sitemap && !a.urls) fail('give the old URLs with --sitemap or --urls');
135
147
  if (a['old-base'] !== undefined && !/^https?:\/\/[^/]/i.test(a['old-base'])) fail('--old-base must be an http(s) URL');
136
148
  const userAgent = a['user-agent'] ?? defaultUserAgent(pkg.version);
149
+ if (!subcommand && (a.port !== undefined || a['no-open'])) fail('--port and --no-open only apply to redirect-map-plan ui');
150
+
151
+ if (subcommand === 'ui') {
152
+ // The flags fill in the form; nothing runs until the page asks.
153
+ if (a.from !== undefined && !SOURCES.includes(a.from)) fail(`--from must be one of ${SOURCES.join(', ')}`);
154
+ if (a.to !== undefined && !TARGETS.includes(a.to)) fail(`--to must be one of ${TARGETS.join(', ')}`);
155
+ if (a.from && a.to) {
156
+ const problem = pairProblem(a.from, a.to);
157
+ if (problem) fail(problem);
158
+ }
159
+ const { startUi, DEFAULT_PORT } = await import('../src/ui/server.js');
160
+ const chosen = integer(a.port, 'port', { min: 0, max: 65535 });
161
+ const local = (v) => (/^https?:\/\//i.test(v) ? v : resolve(v));
162
+ const settings = {
163
+ port: chosen ?? DEFAULT_PORT,
164
+ open: !a['no-open'],
165
+ version: pkg.version,
166
+ userAgent,
167
+ outDir: a.out ?? 'redirect-plan',
168
+ // Local paths stay on this side: the page only learns file names.
169
+ defaults: {
170
+ sitemaps: (a.sitemap ?? []).map(local),
171
+ urlLists: (a.urls ?? []).map(local),
172
+ oldRedirects: a['old-redirects'] ? resolve(a['old-redirects']) : undefined,
173
+ rulesFile: a.rules ? resolve(a.rules) : undefined,
174
+ oldBase: a['old-base'],
175
+ from: a.from,
176
+ to: a.to,
177
+ blogHandle: handle(a['blog-handle'], 'blog-handle', 'news'),
178
+ postsCollection: handle(a['posts-collection'], 'posts-collection', 'blog'),
179
+ titles: Boolean(a.titles),
180
+ ignoreRobots: Boolean(a['ignore-robots']),
181
+ allowPrivateNetwork: Boolean(a['allow-private-network']),
182
+ delay: a.delay === undefined ? undefined : integer(a.delay, 'delay', { min: 0, max: 60_000 }),
183
+ concurrency: a.concurrency === undefined ? undefined : integer(a.concurrency, 'concurrency', { min: 1, max: 16 }),
184
+ timeout: a.timeout === undefined ? undefined : integer(a.timeout, 'timeout', { min: 1000, max: 120_000 }),
185
+ limit: a.limit === undefined ? undefined : integer(a.limit, 'limit', { min: 1, max: 10_000_000 }),
186
+ },
187
+ };
188
+ let ui;
189
+ try {
190
+ ui = await startUi(settings);
191
+ } catch (err) {
192
+ if (err.code !== 'EADDRINUSE') fail(err.message, 1);
193
+ if (chosen !== undefined) fail(`port ${chosen} is in use; pick another with --port`);
194
+ // Our usual port is taken (another copy running?): use any free one.
195
+ ui = await startUi({ ...settings, port: 0 }).catch((e) => fail(e.message, 1));
196
+ }
197
+ process.stdout.write(`\nredirect-map-plan is running at\n\n ${ui.url}\n\n${a['no-open'] ? 'Open that address in your browser.' : 'It should open in your browser; if not, open that address.'} The address includes a private access token: don't share it.\nPress Ctrl+C to stop.\n`);
198
+ const stop = async () => {
199
+ await ui.close();
200
+ process.exit(0);
201
+ };
202
+ process.on('SIGINT', stop);
203
+ process.on('SIGTERM', stop);
204
+ await new Promise(() => {}); // the server keeps running until Ctrl+C
205
+ }
206
+
207
+ if (!a.sitemap && !a.urls) fail('give the old URLs with --sitemap or --urls');
137
208
  const fetchOptions = {
138
209
  concurrency: integer(a.concurrency, 'concurrency', { min: 1, max: 16 }) ?? 4,
139
210
  delayMs: integer(a.delay, 'delay', { min: 0, max: 60_000 }) ?? 250,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redirect-map-plan",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Plan a website migration's redirect map before the move: which old URLs keep their address on the new platform, which keep it with one setting, and which must change. Writes the redirect file in the platform's import format, ready to test with redirect-map-check.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,7 @@
22
22
  "demo": "node demo/run.js"
23
23
  },
24
24
  "dependencies": {
25
- "redirect-map-check": "^0.2.0"
25
+ "redirect-map-check": "^0.2.1"
26
26
  },
27
27
  "engines": {
28
28
  "node": ">=22"
package/src/open.js ADDED
@@ -0,0 +1,22 @@
1
+ // Open a URL or file in the default browser. No shell is involved, so odd characters in
2
+ // a path can't be interpreted as commands. Failing to open is never an error: we always
3
+ // print the address as well.
4
+
5
+ import { spawn } from 'node:child_process';
6
+
7
+ export function openInBrowser(target) {
8
+ const [cmd, args] =
9
+ process.platform === 'darwin'
10
+ ? ['open', [target]]
11
+ : process.platform === 'win32'
12
+ ? ['explorer.exe', [target]]
13
+ : ['xdg-open', [target]];
14
+ try {
15
+ const child = spawn(cmd, args, { stdio: 'ignore', detached: true, windowsHide: true });
16
+ child.on('error', () => {});
17
+ child.unref();
18
+ return true;
19
+ } catch {
20
+ return false;
21
+ }
22
+ }
package/src/plan.js CHANGED
@@ -207,9 +207,19 @@ export async function buildPlan(input) {
207
207
  respectRobots: options.respectRobots,
208
208
  allowPrivateNetwork: options.allowPrivateNetwork,
209
209
  notes,
210
+ signal: options.signal,
210
211
  });
212
+ // Progress for an interface: onPhase(name, detail) at each step, onProgress(done, total) while
213
+ // titles are read. A fired options.signal stops the run with code ECANCELLED.
214
+ const phase = (name, detail = {}) => options.onPhase?.(name, detail);
215
+ const stopIfCancelled = () => {
216
+ if (options.signal?.aborted) throw Object.assign(new Error('The plan was cancelled.'), { code: 'ECANCELLED' });
217
+ };
218
+ // confineTo: a folder of dropped files; a local sitemap index there may only point inside it.
219
+ const readOpts = { signal: options.signal, ...(options.confineTo ? { confineTo: options.confineTo } : {}) };
211
220
 
212
221
  try {
222
+ stopIfCancelled();
213
223
  // Hosts the user named are trusted (the checker's private-network guard allows them).
214
224
  for (const value of [...(options.sitemaps ?? []), ...(options.urlLists ?? []), options.oldRedirects, options.oldBase]) {
215
225
  if (value && isHttp(value)) await fetcher.trustHost(value);
@@ -218,16 +228,19 @@ export async function buildPlan(input) {
218
228
  // 1. Read the old URLs, remembering which sitemap file each came from.
219
229
  const raw = [];
220
230
  const sitemapFiles = [];
231
+ phase('read');
221
232
  for (const src of options.sitemaps ?? []) {
222
233
  const entrySources = [];
223
- await loadSitemapUrls(src, fetcher, { notes, entrySources, partialHint: PARTIAL_HINT });
234
+ await loadSitemapUrls(src, fetcher, { notes, entrySources, partialHint: PARTIAL_HINT, ...readOpts });
235
+ stopIfCancelled();
224
236
  for (const { from, locs } of entrySources) {
225
237
  sitemapFiles.push(String(from));
226
238
  for (const loc of locs) raw.push({ value: loc, source: 'sitemap', sitemapFile: String(from) });
227
239
  }
228
240
  }
229
241
  for (const src of options.urlLists ?? []) {
230
- for (const value of parseUrlList(await loadText(src, fetcher, { notes }))) raw.push({ value, source: 'list' });
242
+ for (const value of parseUrlList(await loadText(src, fetcher, { notes, signal: options.signal }))) raw.push({ value, source: 'list' });
243
+ stopIfCancelled();
231
244
  }
232
245
  const base = options.oldBase ?? raw.map((r) => toUrl(r.value)).find(Boolean)?.origin ?? 'http://old-site.invalid';
233
246
  if (!options.oldBase && raw.some((r) => !isHttp(r.value))) {
@@ -244,6 +257,7 @@ export async function buildPlan(input) {
244
257
  let items = [...byKey.values()];
245
258
  if (!items.length) throw Object.assign(new Error('No old URLs found. Check the sitemap or the URL list.'), { code: 'EINPUT' });
246
259
  if (options.limit) items = items.slice(0, options.limit);
260
+ phase('place', { urls: items.length });
247
261
  // www and the bare domain count as one site.
248
262
  const hosts = [...new Set(items.map((i) => foldHost(i.host)))];
249
263
  const onSite = (host) => hosts.includes(foldHost(host));
@@ -254,7 +268,7 @@ export async function buildPlan(input) {
254
268
  // 2. Rules file.
255
269
  let rulesFile = { pins: new Map(), prefixes: [], problems: [] };
256
270
  if (options.rulesFile) {
257
- const rulesText = await loadText(options.rulesFile, fetcher, { notes });
271
+ const rulesText = await loadText(options.rulesFile, fetcher, { notes, signal: options.signal });
258
272
  rulesFile = inputError('the rules file', () => parseRulesFile(rulesText));
259
273
  notes.push(...rulesFile.problems);
260
274
  }
@@ -393,7 +407,8 @@ export async function buildPlan(input) {
393
407
  for (const x of planned) if (!byLowerPath.has(x.path.toLowerCase())) byLowerPath.set(x.path.toLowerCase(), x.path);
394
408
  const readRules = new Set();
395
409
  if (options.oldRedirects) {
396
- const oldText = await loadText(options.oldRedirects, fetcher, { notes });
410
+ phase('old-redirects');
411
+ const oldText = await loadText(options.oldRedirects, fetcher, { notes, signal: options.signal });
397
412
  const map = inputError('the old redirects', () => parseRedirectMap(oldText));
398
413
  for (const pr of map.problems ?? []) oldRedirectNotes.push(`Old redirects, line ${pr.line ?? '?'}: ${pr.message ?? pr}`);
399
414
  // The old platform's own syntax: Webflow exports hold escaped paths and pattern rows.
@@ -576,16 +591,21 @@ export async function buildPlan(input) {
576
591
  }
577
592
  }
578
593
 
594
+ stopIfCancelled();
579
595
  // 8. Optional: old page titles, for later checks (old-pages.json, the checker's format).
580
596
  const pages = {};
581
597
  if (options.titles) {
582
598
  const queue = planned.filter((p) => ['keeps', 'setting', 'changes', 'decide'].includes(p.outcome));
583
599
  const tally = { read: 0, robots: 0, robotsError: 0, offsite: 0, status: 0, notHtml: 0, failed: 0 };
584
600
  let i = 0;
601
+ let done = 0;
602
+ phase('titles', { pages: queue.length });
603
+ options.onProgress?.(0, queue.length);
585
604
  const worker = async () => {
586
- while (i < queue.length) {
605
+ while (i < queue.length && !options.signal?.aborted) {
587
606
  const p = queue[i++];
588
607
  const res = await fetcher.follow(p.url, { wantBody: true, checkRobots: true });
608
+ if (res?.errorCode === 'ECANCELLED') break;
589
609
  // With checkRobots, the private-network guard and an unreachable robots.txt also
590
610
  // come back as EROBOTS: blocked.kind says which.
591
611
  const kind = res?.blocked?.kind;
@@ -603,9 +623,13 @@ export async function buildPlan(input) {
603
623
  pages[p.key] = { url: p.url, title: p.title, h1: p.h1 };
604
624
  tally.read += 1;
605
625
  }
626
+ done += 1;
627
+ options.onProgress?.(done, queue.length);
628
+ options.onPage?.({ url: p.url, title: p.title ?? '', status: res?.status ?? 0 });
606
629
  }
607
630
  };
608
631
  await Promise.all(Array.from({ length: Math.max(1, options.concurrency) }, worker));
632
+ stopIfCancelled();
609
633
  const missed = [
610
634
  [tally.robots, 'blocked by robots.txt'],
611
635
  [tally.robotsError, 'skipped because robots.txt answered with an error'],
@@ -651,6 +675,10 @@ export async function buildPlan(input) {
651
675
  requests: fetcher.requestCount ?? 0,
652
676
  },
653
677
  };
678
+ } catch (err) {
679
+ // Whatever was in flight when the signal fired (a sitemap read, a request) is a cancel.
680
+ if (options.signal?.aborted && err?.code !== 'ECANCELLED') throw Object.assign(new Error('The plan was cancelled.'), { code: 'ECANCELLED' });
681
+ throw err;
654
682
  } finally {
655
683
  if (ownFetcher) fetcher.close();
656
684
  }
@@ -658,14 +686,15 @@ export async function buildPlan(input) {
658
686
 
659
687
  /** Read only the URLs and say which source platform they look like (for when --from is missing). */
660
688
  export async function detectSource(input) {
661
- const fetcher = new Fetcher({ userAgent: input.userAgent ?? defaultUserAgent(), productToken: 'redirect-map-plan', concurrency: input.concurrency ?? DEFAULTS.concurrency, timeoutMs: input.timeoutMs ?? DEFAULTS.timeoutMs, delayMs: input.delayMs ?? DEFAULTS.delayMs, allowPrivateNetwork: input.allowPrivateNetwork, respectRobots: input.respectRobots ?? true, notes: [] });
689
+ const fetcher = new Fetcher({ userAgent: input.userAgent ?? defaultUserAgent(), productToken: 'redirect-map-plan', concurrency: input.concurrency ?? DEFAULTS.concurrency, timeoutMs: input.timeoutMs ?? DEFAULTS.timeoutMs, delayMs: input.delayMs ?? DEFAULTS.delayMs, allowPrivateNetwork: input.allowPrivateNetwork, respectRobots: input.respectRobots ?? true, notes: [], signal: input.signal });
690
+ const readOpts = { signal: input.signal, ...(input.confineTo ? { confineTo: input.confineTo } : {}) };
662
691
  try {
663
692
  for (const value of [...(input.sitemaps ?? []), ...(input.urlLists ?? [])]) if (isHttp(value)) await fetcher.trustHost(value);
664
693
  const items = [];
665
694
  const files = [];
666
695
  for (const src of input.sitemaps ?? []) {
667
696
  const entrySources = [];
668
- await loadSitemapUrls(src, fetcher, { entrySources, partialHint: PARTIAL_HINT });
697
+ await loadSitemapUrls(src, fetcher, { entrySources, partialHint: PARTIAL_HINT, ...readOpts });
669
698
  for (const { from, locs } of entrySources) {
670
699
  files.push(String(from));
671
700
  for (const loc of locs) {
@@ -675,7 +704,7 @@ export async function detectSource(input) {
675
704
  }
676
705
  }
677
706
  for (const src of input.urlLists ?? []) {
678
- for (const v of parseUrlList(await loadText(src, fetcher))) {
707
+ for (const v of parseUrlList(await loadText(src, fetcher, { signal: input.signal }))) {
679
708
  const it = toItem(v, input.oldBase ?? 'http://old-site.invalid');
680
709
  if (it) items.push(it);
681
710
  }
@@ -683,6 +712,9 @@ export async function detectSource(input) {
683
712
  // Sitemap file names count too (the index itself, e.g. wp-sitemap.xml).
684
713
  for (const s of input.sitemaps ?? []) files.push(String(s));
685
714
  return suggestPlatform(items, buildContext(items, { sitemapFiles: files }));
715
+ } catch (err) {
716
+ if (input.signal?.aborted) throw Object.assign(new Error('The suggestion was cancelled.'), { code: 'ECANCELLED' });
717
+ throw err;
686
718
  } finally {
687
719
  fetcher.close();
688
720
  }