Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microlinkhq/metascraper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.52.1
Choose a base ref
...
head repository: microlinkhq/metascraper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.53.0
Choose a head ref
  • 2 commits
  • 70 files changed
  • 2 contributors

Commits on Jul 30, 2026

  1. feat(helpers): read the declared protocol instead of resolving it (#864)

    * perf(helpers): read protocol without a thrown URL construction
    
    `protocol` resolved the scheme through `new URL` inside a try/catch, so every
    schemeless value paid for a constructed and thrown exception to arrive at ''.
    Relative hrefs are the common input for callers walking a document's links.
    
    A value with no scheme can never parse without a base, so it resolves to ''
    without touching the URL parser. Anything carrying a scheme still goes through
    `new URL`, which keeps the cases where parsing the whole URL is what decides the
    answer: `new URL('http://')` throws, so `protocol('http://')` stays ''.
    
    100k calls, best of 3:
    
      relative hrefs   299.3ms -> 1.9ms   155x
      mixed            162.2ms -> 8.5ms    19x
      absolute http     14.2ms -> 15.4ms  0.9x
    
    Inputs that do carry a scheme pay one extra regex test, about 8% on a ~140ns
    call, since the URL construction happens either way.
    
    Output is unchanged. Verified by differential fuzz against the previous
    implementation over 200,074 inputs, including leading control characters, tabs
    and newlines inside the scheme, non-strings, and URLs the parser rejects
    outright: no mismatches.
    
    * feat(helpers): read the declared protocol instead of resolving it
    
    `protocol` resolved the scheme through `new URL` inside a try/catch, so a value
    without a scheme constructed a URL, threw, and got caught on the way to ''.
    Relative hrefs are the common input for callers walking a document's links, which
    put the exception on the hot path.
    
    Which scheme a value declares is a lexical question, so it is now read directly.
    
    100k calls, best of 3:
    
      relative hrefs   299.4ms -> 2.6ms   116x
      mixed            157.1ms -> 3.6ms    44x
      absolute http     14.7ms -> 4.0ms   3.7x
      non-http schemes  13.5ms -> 4.3ms   3.2x
    
    The scheme is read after the cleanup the URL parser applies before reading it
    itself: a leading C0 control or space is skipped and every ASCII tab or newline is
    removed, so ' mai\tlto:a@b' still declares `mailto`.
    
    Output changes for one class of input: a URL whose authority the parser rejects.
    
      protocol('http://')   '' -> 'http'
      protocol('http://[')  '' -> 'http'
      protocol('foo://[')   '' -> 'foo'
    
    '' described the whole URL rather than the scheme sitting in front of it. Whether
    a URL is usable is what `isUrl` answers.
    
    Verified by differential fuzz against the previous implementation over 300,079
    inputs, including leading control characters, tabs and newlines inside the scheme,
    and non-strings: 300,070 identical, 9 divergences, every one of them the class
    above, and none outside it.
    
    * perf(helpers): read the protocol in a single scan
    
    The regex ran over a value that a trim loop and three `includes` scans had
    already walked. One charCode pass answers it, with the tab/newline removal
    demoted to the rare path that needs it.
    
    100k calls per set, best of 5:
    
    | input             | before | after |       |
    |-------------------|--------|-------|-------|
    | relative hrefs    | 2.52ms | 0.80ms| 3.2x  |
    | mixed             | 3.20ms | 1.25ms| 2.6x  |
    | absolute http     | 4.64ms | 1.89ms| 2.5x  |
    | non-http schemes  | 4.27ms | 1.80ms| 2.4x  |
    | tabs / leading ws | 8.52ms | 6.58ms| 1.3x  |
    
    Differential fuzz against the previous implementation over 500,044 inputs:
    0 mismatches.
    
    `normalizeUrl` asked the same question through `new URL`, so it now reads
    the helper and drops a URL construction per call.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_014CoQ8BQTgwWhjmLpS8jqTE
    
    * perf(helpers): inline the scheme character classes
    
    V8 was not inlining `isSchemeHead`/`isSchemeChar`, and `toLowerCase` was
    called on schemes that were already lowercase. Both are now decided in the
    loop that is already reading the characters.
    
    100k calls per set, best of 9, against a noise floor of +/-15% measured with
    a byte-identical clone of the previous body:
    
    | input            | before | after  |       |
    |------------------|--------|--------|-------|
    | mixed            | 1.56ms | 1.16ms | -25%  |
    | absolute http    | 1.88ms | 1.48ms | -22%  |
    | non-http schemes | 1.79ms | 1.42ms | -21%  |
    
    Differential fuzz against both earlier implementations over 500,044 inputs:
    0 mismatches.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_014CoQ8BQTgwWhjmLpS8jqTE
    
    * refactor(helpers): drop the single-use temporaries in protocol
    
    `isLower` was an alias for the flag's initial value and `isDigit` named a
    class that every neighbouring line inlines. Measured against the previous
    body: within the +/-15% noise floor on every input class.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_014CoQ8BQTgwWhjmLpS8jqTE
    
    * test(helpers): give the strip comment a subject
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_014CoQ8BQTgwWhjmLpS8jqTE
    
    ---------
    
    Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
    Kikobeats and claude authored Jul 30, 2026
    Configuration menu
    Copy the full SHA
    2d72298 View commit details
    Browse the repository at this point in the history
  2. chore(release): v5.53.0

    Kikobeats committed Jul 30, 2026
    Configuration menu
    Copy the full SHA
    440ebd1 View commit details
    Browse the repository at this point in the history
Loading