markdown-parity-check 0.2.40 → 0.2.41

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/README.md CHANGED
@@ -78,10 +78,10 @@ A value that is outside these ranges, or that is not a plain run of digits, stop
78
78
 
79
79
  ### Example output
80
80
 
81
- This is the text report for the matching fixture pair in this repository, run with version 0.2.40 on 2026-11-15. The exact command is in the Development section below. The text report ends with a list of limitations, which is omitted here:
81
+ This is the text report for the matching fixture pair in this repository, run with version 0.2.41 on 2026-11-22. The exact command is in the Development section below. The text report ends with a list of limitations, which is omitted here:
82
82
 
83
83
  ```text
84
- markdown-parity-check 0.2.40 (offline mode)
84
+ markdown-parity-check 0.2.41 (offline mode)
85
85
  Result: PASS (0 error(s), 0 warning(s), 1 info)
86
86
 
87
87
  HTML: test/fixtures/same/page.html (file, 1,017 bytes, base https://example.com/page)
@@ -151,7 +151,7 @@ The choice follows the type of the response, not the request. Any other response
151
151
 
152
152
  JavaScript is not executed. Content that a page builds in the browser is compared as the server sent it. Block matching is heuristic, so some layouts need an explicit selector. Reports mask URL query values and fragments and remove the user name and password of an address with a scheme, such as `https://user:password@host/`. Excerpts may still contain private page content. Review a report before you share it.
153
153
 
154
- The masking is a display safeguard that does not hide ordinary text, so it has limits, and this paragraph is the full list. It removes the user name and password even when a tab, a line break or a space sits inside the user information, provided that the user information holds a colon, as in `user:password`. A user name alone, with no colon, is masked when a tab, a vertical tab or a form feed sits inside it, and is shown when a space, a no-break space, a line feed or a carriage return does, because a line break or a space between an address and an e-mail address is ordinary text. On a bare host name without a scheme, a query or a fragment is masked only when it holds an equals sign, so an anchor such as `example.com/docs/guide#step-3` and a path segment are shown. Not masked: a bracketed IPv6 host, a host with a trailing dot, a name with no dot other than `localhost` and an scp-style `git@host:path`. A scheme-less `user:password@host.example/path` is masked as `user:***@host.example/path`, and so is the e-mail link that the Markdown parser reads out of it, when a path, a query that holds a value or a fragment that holds an equals sign follows the host name. Without one, as in `user:password@host.example` or `Contact:jane@example.com`, it is shown, because text alone cannot tell a user name from a label. The scheme-less form is also shown when its host name holds a letter outside ASCII, or when its colon or at sign is written as a character reference or a fullwidth character. An address after `mailto:`, `xmpp:`, `sip:`, `sips:`, `acct:` or `im:` is shown as written. A plain space or a no-break space right after the colon of the user information, and a password of digits only that is followed by white space, are read as text and shown. The masking changes what a report shows and never what is compared, and a number difference inside a masked part still gives the number finding, with the values left out. In both formats U+200E, U+200F, U+061C, U+2028, U+2029 and the tag characters are removed from report text. The text report shows a line feed or a carriage return inside a string from a page or an argument as `\n` or `\r`.
154
+ The masking is a display safeguard that does not hide ordinary text, so it has limits, and this paragraph is the full list. It removes the user name and password even when a tab, a line break or a space sits inside the user information, provided that the user information holds a colon, as in `user:password`. A user name alone, with no colon, is masked when a tab, a vertical tab or a form feed sits inside it, and is shown when a space, a no-break space, a line feed or a carriage return does, because a line break or a space between an address and an e-mail address is ordinary text. On a bare host name without a scheme, a query or a fragment is masked only when it holds an equals sign, so an anchor such as `example.com/docs/guide#step-3` and a path segment are shown. Not masked: a bracketed IPv6 host, a host with a trailing dot, a name with no dot other than `localhost` and an scp-style `git@host:path`. A scheme-less `user:password@host.example/path` is masked as `user:***@host.example/path`, and so is the e-mail link that the Markdown parser reads out of it, when a path, a query that holds a value or a fragment that holds an equals sign follows the host name. Without one, as in `user:password@host.example` or `Contact:jane@example.com`, it is shown, because text alone cannot tell a user name from a label. The scheme-less form is also shown when its host name holds a letter outside ASCII, or when its colon or at sign is written as a character reference or a fullwidth character. An address after `mailto:`, `xmpp:`, `sip:`, `sips:`, `acct:` or `im:` is shown as written. A link target that holds an `@` is shown as its scheme and `//***`, as `gopher:***` for a non-special scheme such as `gopher:`, or as `***`, when a URL parser and a person could read its user information at different places. A special scheme such as `https:` with fewer than two slashes or backslashes after its colon is one such case, as in `https:/user:password@host.example/x`. An authority with a backslash, a `?` or a `#` before its last `@` and before any `/` is another, as in `https://CORP\erik:password@host.example/x`, and `https://example.com?e=a@b.com` reads the same way. An authority that the URL parser refuses, as with the port in `https://user:pa/ss?password@host.example`, and a `file:` URL are masked as well. So are a scheme that the parser refuses, as in `user_name:password@host.example`, and a non-special scheme such as `gopher:` whose text before the `@` holds a colon. Each of these shapes is masked after a leading Unicode space or a NUL character too. A target of these shapes is shown this way also when it holds no user information, such as `file:///home/a@b.txt`. Not masked: a password that starts with `/` or with digits and `/`, as in `https://user:/password@host.example`, which the URL parser reads as a host and a path and which text alone cannot tell from a path that holds an `@`, such as `https://localhost:8080/team@example.com`, and a relative path such as `/user:password@host.example`, which both readers take as a path. A plain space or a no-break space right after the colon of the user information, and a password of digits only that is followed by white space, are read as text and shown. The masking changes what a report shows and never what is compared, and a number difference inside a masked part still gives the number finding, with the values left out. In both formats U+200E, U+200F, U+061C, U+2028, U+2029 and the tag characters are removed from report text. The text report shows a line feed or a carriage return inside a string from a page or an argument as `\n` or `\r`.
155
155
 
156
156
  A link target longer than 8192 characters stops the run with exit code 2 and an error that names the limit and does not repeat the target. The comparison handles a target once for every link, block or reference that touches it, so the time grew with the length of the target times that count. The limit applies to the target as the page or the Markdown wrote it, before any resolution.
157
157
 
@@ -223,7 +223,7 @@ The test suite runs the bounded case and asserts no time. When a limit is exceed
223
223
 
224
224
  The library has no time limit and no memory limit of its own. A program that compares untrusted documents needs a time limit and a memory limit of its own, enforced outside the calling thread, for example in a worker thread, in a separate process or in an isolate with a CPU limit. `run` is synchronous, so a timer in the same thread cannot interrupt it, and the command line uses a worker thread for that reason. A link target over 8192 characters is a `RunError`, as described under the limits of the method.
225
225
 
226
- Some costs come from the parsers and are not bounded by this package. The table rule of `micromark-extension-gfm` and the bare link rule of `mdast-util-find-and-replace` take more than linear time on very large inputs. In hand timings on one development machine, a Markdown table of 10 000 one-cell rows and one row of 30 000 cells, under 250 kB, took tens of seconds to parse, and 100 000 bare links in one paragraph, 2.8 MB, took tens of seconds as well. A deeply nested HTML document needs memory in proportion to its blocks times their nesting depth. A document of 650 000 paragraphs inside 1 000 nested elements, 5 MiB, ran out of memory at about 4 GB, which ends a library process. The command line stops the same run with exit code 2, and the test suite does not repeat these timings.
226
+ Some costs come from the parsers and are not bounded by this package. The table rule of `micromark-extension-gfm` and the bare link rule of `mdast-util-find-and-replace` take more than linear time, and for a table the cost shows at ordinary sizes. In hand timings of `run` with Node.js 26 on one development machine on 2026-11-22, a two-column table of 8 KiB took about 40 ms, 16 KiB about 110 ms, 32 KiB about 600 ms and 64 KiB, 6 552 rows, about 3 s, so from 16 KiB on each doubling took about five times as long. In earlier hand timings a table of 10 000 one-cell rows and one row of 30 000 cells, under 250 kB, took tens of seconds to parse, and 100 000 bare links in one paragraph, 2.8 MB, took tens of seconds as well. A deeply nested HTML document needs memory in proportion to its blocks times their nesting depth. A document of 650 000 paragraphs inside 1 000 nested elements, 5 MiB, ran out of memory at about 4 GB, which ends a library process. The command line stops the same run with exit code 2, and the test suite does not repeat these timings.
227
227
 
228
228
  The caller fetches the pages and decides which addresses are allowed. The address policy that the command applies is exported as `assertPublicHost` and `isPublicAddress`. `assertPublicHost` takes `url.hostname` of a parsed `URL`, because the URL parser has already written a literal such as `2130706433` or `0x7f.0.0.1` as dotted decimal by then. A caller that checks the host and the resolved addresses and then lets `fetch()` resolve the name again can be sent to another address by a DNS answer that changes in between. The package exports no helper that pins the checked address. The command connects to the address it checked.
229
229
 
@@ -272,12 +272,12 @@ Only after that check does it create the GitHub release with the verified tarbal
272
272
  GitHub Actions publishes every version from 0.1.2 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
273
273
 
274
274
  ```sh
275
- mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.40 --ignore-scripts && npm audit signatures
275
+ mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.41 --ignore-scripts && npm audit signatures
276
276
  ```
277
277
 
278
278
  `npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/markdown-parity-check`, the workflow file `.github/workflows/release.yml` and the commit that produced the tarball. The npm version page shows them under Provenance.
279
279
 
280
- Tag `v0.2.40` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.40 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
280
+ Tag `v0.2.41` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.41 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
281
281
 
282
282
  ## Security
283
283
 
package/dist/src/cli.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { type FetchOptions, type FetchResult } from './fetch.js';
3
- export declare const HELP = "markdown-parity-check 0.2.40\nCompares the main content of a web page's HTML and Markdown representations and reports concrete\nmissing, added and changed blocks.\n\nUsage:\n markdown-parity-check --url <https://example.com/page> [--markdown-url <url>] [options]\n markdown-parity-check --html-file <page.html> --markdown-file <page.md> [--base-url <url>] [options]\n\nModes:\n --url <url> Fetch <url> twice: with Accept: text/html and with Accept: text/markdown.\n --markdown-url <url> Fetch the Markdown from this explicit address instead (requires --url).\n --html-file <path> Offline: local HTML file (requires --markdown-file).\n --markdown-file <path> Offline: local Markdown file (requires --html-file).\n --base-url <url> Offline: base for resolving relative links on both sides.\n\nOptions:\n --html-profile generic|starlight\n HTML extraction rules (default: generic). Starlight includes inactive tab panels.\n --selector <css> CSS selector for the HTML main content (default: main, article, [role=main], then body).\n --front-matter keep|strip\n Markdown front matter. keep (default) removes nothing and warns when the document\n starts with a YAML-looking fenced block; strip removes that leading block.\n --format text|json Report format (default: text).\n --output <path> Write the report to a file instead of stdout. Refuses to overwrite an input file.\n --timeout-ms <n> Timeout in milliseconds for each fetch and for the parse-and-compare step\n (default: 15000). When it runs out the exit code is 2.\n --max-bytes <n> Cap on decoded response bytes per fetch (default: 5242880).\n --strict Treat warnings as rejecting findings too.\n --help, -h Show this help.\n --version, -V Show the version.\n\nExit codes:\n 0 comparison completed, no rejecting finding\n 1 comparison completed, rejecting content or delivery differences found\n 2 input, fetch, parse or report error prevented a reliable comparison\n\nOnly http(s) URLs to public addresses are fetched; loopback, private, link-local and other non-public\naddresses are refused, also behind DNS and redirects. No JavaScript is executed. Exit 0 does not prove\nsemantic equivalence.\n";
3
+ export declare const HELP = "markdown-parity-check 0.2.41\nCompares the main content of a web page's HTML and Markdown representations and reports concrete\nmissing, added and changed blocks.\n\nUsage:\n markdown-parity-check --url <https://example.com/page> [--markdown-url <url>] [options]\n markdown-parity-check --html-file <page.html> --markdown-file <page.md> [--base-url <url>] [options]\n\nModes:\n --url <url> Fetch <url> twice: with Accept: text/html and with Accept: text/markdown.\n --markdown-url <url> Fetch the Markdown from this explicit address instead (requires --url).\n --html-file <path> Offline: local HTML file (requires --markdown-file).\n --markdown-file <path> Offline: local Markdown file (requires --html-file).\n --base-url <url> Offline: base for resolving relative links on both sides.\n\nOptions:\n --html-profile generic|starlight\n HTML extraction rules (default: generic). Starlight includes inactive tab panels.\n --selector <css> CSS selector for the HTML main content (default: main, article, [role=main], then body).\n --front-matter keep|strip\n Markdown front matter. keep (default) removes nothing and warns when the document\n starts with a YAML-looking fenced block; strip removes that leading block.\n --format text|json Report format (default: text).\n --output <path> Write the report to a file instead of stdout. Refuses to overwrite an input file.\n --timeout-ms <n> Timeout in milliseconds for each fetch and for the parse-and-compare step\n (default: 15000). When it runs out the exit code is 2.\n --max-bytes <n> Cap on decoded response bytes per fetch (default: 5242880).\n --strict Treat warnings as rejecting findings too.\n --help, -h Show this help.\n --version, -V Show the version.\n\nExit codes:\n 0 comparison completed, no rejecting finding\n 1 comparison completed, rejecting content or delivery differences found\n 2 input, fetch, parse or report error prevented a reliable comparison\n\nOnly http(s) URLs to public addresses are fetched; loopback, private, link-local and other non-public\naddresses are refused, also behind DNS and redirects. No JavaScript is executed. Exit 0 does not prove\nsemantic equivalence.\n";
4
4
  export declare class CliError extends Error {
5
5
  }
6
6
  export interface CliArgs {
@@ -1,6 +1,6 @@
1
1
  // The comparison core: aligns blocks and turns the alignment into findings. Pure and network-free.
2
2
  import { align, resolveLimits, AlignmentLimitError, UNCERTAIN_THRESHOLD } from './align.js';
3
- import { codeWhitespaceKey, excerpt, hrefDifference, looseNormalize, maskBareUserinfo, maskHref, redactText, relativeHrefRelation, textKey, trimHref, visibleNumbers } from './normalize.js';
3
+ import { codeWhitespaceKey, excerpt, hrefDifference, looseNormalize, maskBareUserinfo, maskHref, movedUserinfoMask, redactText, relativeHrefRelation, textKey, trimHref, visibleNumbers } from './normalize.js';
4
4
  // The excerpt masks the whole block text before it cuts it, so it is computed once per block. Up to 0.2.11 every
5
5
  // finding computed it again, and a block with thousands of link findings did that thousands of times (0.2.12).
6
6
  const sides = new WeakMap();
@@ -62,7 +62,9 @@ export function diffNumbers(a, b) {
62
62
  const linkText = (l, other) => (l.masked || other?.masked ? '***' : redactText(l.shown ?? l.text));
63
63
  // maskBareUserinfo runs before maskHref as well as after it: maskHref drops the fragment, and a target such as
64
64
  // `user:secret@host.example#a=b` has no other delimiter, so after maskHref the shape would no longer be recognised.
65
- const linkHref = (l, href) => (l.masked ? '***' : maskBareUserinfo(maskHref(maskBareUserinfo(href))));
65
+ // movedUserinfoMask reads the written target first: a target such as `https:/user:secret@host.example/x` resolves
66
+ // against a base of the same scheme into a path that holds the user information, and only the scheme is shown then.
67
+ const linkHref = (l, href) => (l.masked ? '***' : movedUserinfoMask(l.rawHref) ?? maskBareUserinfo(maskHref(maskBareUserinfo(href))));
66
68
  /**
67
69
  * Pairs the HTML block's links with the Markdown block's, in three steps.
68
70
  *
@@ -179,6 +179,40 @@ export declare function maskUrl(url: string): string;
179
179
  * display. The user name goes with the password, because either one can be the secret. Up to 0.2.9 both
180
180
  * stayed in the output, and so in the error of a refused URL (found by an outside review 2026-09-22). */
181
181
  export declare function maskHref(href: string): string;
182
+ /**
183
+ * What a report shows in place of a link target whose user information the URL parser and a person may read at
184
+ * different places, or null when maskHref and maskBareUserinfo show the target safely. It is decided from the written
185
+ * target alone, whatever the base, so one link reads the same in every finding, the way turva-llms-txt-validator
186
+ * shows an ambiguous address: only the scheme and "//***", or "***" when the text before the colon may itself be the
187
+ * user name. Found by an outside fuzz run of 0.2.40 on 2026-11-22 (P3-1) and by four independent checks of 0.2.41
188
+ * before release. Only a target that holds an "@" counts, and these shapes are masked:
189
+ *
190
+ * - a special scheme with fewer than two slashes or backslashes after its colon, as in `https:/user:secret@host/x`.
191
+ * Against a base of the same scheme the parser reads a relative path, so `https://example.com/user:secret@host/x`
192
+ * was shown.
193
+ * - an authority, after two slashes (or backslashes, for a special scheme or no scheme), with a backslash, "?" or "#"
194
+ * before the last "@" and before the first "/", as in `https://CORP\erik:secret@host/x` or
195
+ * `https://user:x?secret@host/x`. The parser ends the host there, so the secret was shown in a path or as a query
196
+ * name. `https://example.com?e=a@b.com` reads the same way and is masked too.
197
+ * - an authority that the parser refuses, as with the port `pa` in `https://user:pa/ss?secret@host`.
198
+ * - a `file:` URL. Its host is empty, so `file:///user:secret@host` kept the user information in its path.
199
+ * - a non-special scheme with no "//", or with an empty authority as in `gopher:///user:secret@host`, whose text
200
+ * before the last "@" holds a colon, as in `gopher:user:secret@host`, which the parser reads as an opaque path. Not
201
+ * for an address scheme such as mailto, and not for `user:secret@host.example/p`, whose user name is the scheme
202
+ * word and which maskBareUserinfo masks.
203
+ * - a scheme word that the parser refuses, as in `user_name:secret@host`, `my_app:user:secret@host` or
204
+ * `ht tps:/user:secret@host`, which resolves as a relative path.
205
+ * - any target with an "@" after a leading Unicode space or U+FFFD, which the parser keeps, so it reads the whole
206
+ * target as a relative path. Only *** is shown then.
207
+ * - a relative target with a "?" or "#" before its last "@" and a colon between them, as in `u?x:secret@host`,
208
+ * which put the secret into a query name. Only *** is shown.
209
+ *
210
+ * Not masked, and named in the README: a password that starts with "/" or with digits and "/", as in
211
+ * `https://user:/secret@host`, which the parser reads as a host, a port and a path and which text alone cannot tell
212
+ * from a path that holds an "@", such as `https://localhost:8080/team@example.com`; and a relative path such as
213
+ * `/user:secret@host`, which both readers take as a path.
214
+ */
215
+ export declare function movedUserinfoMask(written: string): string | null;
182
216
  /** Describes how two hrefs differ without revealing masked parts. */
183
217
  export declare function hrefDifference(a: string, b: string): string;
184
218
  export type HrefRelation = 'same' | 'different' | 'uncertain';
@@ -1065,6 +1065,98 @@ export function maskHref(href) {
1065
1065
  }
1066
1066
  }
1067
1067
  const SPECIAL_SCHEMES = new Set(['ftp', 'file', 'http', 'https', 'ws', 'wss']);
1068
+ /** Leading characters a reader does not see but the URL parser keeps: the Unicode white space, U+0085, U+180E,
1069
+ * U+200B and U+FFFD, which the Markdown parser writes for a NUL. */
1070
+ const EDGE_INVISIBLE = new RegExp('^[\\s' + String.fromCharCode(0x85, 0x180e, 0x200b, 0xfffd) + ']+');
1071
+ /**
1072
+ * What a report shows in place of a link target whose user information the URL parser and a person may read at
1073
+ * different places, or null when maskHref and maskBareUserinfo show the target safely. It is decided from the written
1074
+ * target alone, whatever the base, so one link reads the same in every finding, the way turva-llms-txt-validator
1075
+ * shows an ambiguous address: only the scheme and "//***", or "***" when the text before the colon may itself be the
1076
+ * user name. Found by an outside fuzz run of 0.2.40 on 2026-11-22 (P3-1) and by four independent checks of 0.2.41
1077
+ * before release. Only a target that holds an "@" counts, and these shapes are masked:
1078
+ *
1079
+ * - a special scheme with fewer than two slashes or backslashes after its colon, as in `https:/user:secret@host/x`.
1080
+ * Against a base of the same scheme the parser reads a relative path, so `https://example.com/user:secret@host/x`
1081
+ * was shown.
1082
+ * - an authority, after two slashes (or backslashes, for a special scheme or no scheme), with a backslash, "?" or "#"
1083
+ * before the last "@" and before the first "/", as in `https://CORP\erik:secret@host/x` or
1084
+ * `https://user:x?secret@host/x`. The parser ends the host there, so the secret was shown in a path or as a query
1085
+ * name. `https://example.com?e=a@b.com` reads the same way and is masked too.
1086
+ * - an authority that the parser refuses, as with the port `pa` in `https://user:pa/ss?secret@host`.
1087
+ * - a `file:` URL. Its host is empty, so `file:///user:secret@host` kept the user information in its path.
1088
+ * - a non-special scheme with no "//", or with an empty authority as in `gopher:///user:secret@host`, whose text
1089
+ * before the last "@" holds a colon, as in `gopher:user:secret@host`, which the parser reads as an opaque path. Not
1090
+ * for an address scheme such as mailto, and not for `user:secret@host.example/p`, whose user name is the scheme
1091
+ * word and which maskBareUserinfo masks.
1092
+ * - a scheme word that the parser refuses, as in `user_name:secret@host`, `my_app:user:secret@host` or
1093
+ * `ht tps:/user:secret@host`, which resolves as a relative path.
1094
+ * - any target with an "@" after a leading Unicode space or U+FFFD, which the parser keeps, so it reads the whole
1095
+ * target as a relative path. Only *** is shown then.
1096
+ * - a relative target with a "?" or "#" before its last "@" and a colon between them, as in `u?x:secret@host`,
1097
+ * which put the secret into a query name. Only *** is shown.
1098
+ *
1099
+ * Not masked, and named in the README: a password that starts with "/" or with digits and "/", as in
1100
+ * `https://user:/secret@host`, which the parser reads as a host, a port and a path and which text alone cannot tell
1101
+ * from a path that holds an "@", such as `https://localhost:8080/team@example.com`; and a relative path such as
1102
+ * `/user:secret@host`, which both readers take as a path.
1103
+ */
1104
+ export function movedUserinfoMask(written) {
1105
+ const own = urlParserInput(written);
1106
+ const h = own.replace(EDGE_INVISIBLE, '');
1107
+ if (!h.includes('@'))
1108
+ return null;
1109
+ // A leading invisible character makes the parser read the whole target as a relative path, whatever follows it, so
1110
+ // nothing of it is shown (fifth independent check: U+2003 before user:secret@host/p or https:///user:secret@host).
1111
+ if (h !== own)
1112
+ return '***';
1113
+ // The scheme word runs to the first colon unless a slash, backslash, ?, # or @ comes first, so "ht tps:" is a word
1114
+ // the parser refuses, not a relative path (fifth check).
1115
+ const word = /^([^\/\\?#@:]+):/.exec(h);
1116
+ if (word !== null && !/^[a-z][a-z0-9+.-]*$/i.test(word[1]))
1117
+ return '***';
1118
+ const name = word === null ? '' : word[1].toLowerCase();
1119
+ if (ADDRESS_SCHEMES.has(name))
1120
+ return null;
1121
+ const special = word === null || SPECIAL_SCHEMES.has(name);
1122
+ const rest = word === null ? h : h.slice(word[0].length);
1123
+ const shown = word === null ? '//***' : `${name}://***`;
1124
+ const isSlash = (c) => c === 0x2f || (special && c === 0x5c);
1125
+ if (!(rest.length >= 2 && isSlash(rest.charCodeAt(0)) && isSlash(rest.charCodeAt(1)))) {
1126
+ if (word === null) {
1127
+ // A relative target with a ? or # before its last @ and a colon between them, as in u?x:secret@host, put the
1128
+ // secret into a query name against a base (fifth check), so nothing of it is shown.
1129
+ const cut = h.search(/[?#]/);
1130
+ return cut >= 0 && h.slice(cut, h.lastIndexOf('@')).includes(':') ? '***' : null;
1131
+ }
1132
+ if (special)
1133
+ return shown;
1134
+ return rest.slice(0, rest.lastIndexOf('@')).includes(':') ? `${name}:***` : null;
1135
+ }
1136
+ if (name === 'file')
1137
+ return shown;
1138
+ // A non-special scheme with an empty authority, as in gopher:///user:secret@host, keeps the rest in its path.
1139
+ if (!special && rest.charCodeAt(2) === 0x2f)
1140
+ return `${name}:***`;
1141
+ let k = 2;
1142
+ while (k < rest.length && isSlash(rest.charCodeAt(k)))
1143
+ k++;
1144
+ const tail = rest.slice(k);
1145
+ const lastAt = tail.lastIndexOf('@');
1146
+ if (lastAt <= 0)
1147
+ return null;
1148
+ const slash = tail.indexOf('/');
1149
+ const end = slash >= 0 && slash < lastAt ? slash : lastAt;
1150
+ if (/[\\?#]/.test(tail.slice(0, end)))
1151
+ return shown;
1152
+ try {
1153
+ new URL(word === null ? `https:${h}` : h);
1154
+ }
1155
+ catch {
1156
+ return shown;
1157
+ }
1158
+ return null;
1159
+ }
1068
1160
  /**
1069
1161
  * The href without its user information. The authority is found where the URL parser looks for it: after
1070
1162
  * "scheme:" and any slashes or backslashes for a special scheme, after "//" for any other scheme, and after two
@@ -1,2 +1,2 @@
1
1
  export declare const TOOL_NAME = "markdown-parity-check";
2
- export declare const TOOL_VERSION = "0.2.40";
2
+ export declare const TOOL_VERSION = "0.2.41";
@@ -2,4 +2,4 @@
2
2
  // Cloudflare Worker as well as under Node.js. test/version.test.ts fails the build when these differ
3
3
  // from package.json, which stays the version the release workflow publishes.
4
4
  export const TOOL_NAME = 'markdown-parity-check';
5
- export const TOOL_VERSION = '0.2.40';
5
+ export const TOOL_VERSION = '0.2.41';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-parity-check",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "description": "Compares the main content of a web page's HTML and Markdown representations and reports concrete differences.",
5
5
  "keywords": [
6
6
  "markdown",