Skip to content

Commit c993938

Browse files
committed
Merge branch 'chore/sonar-minor-cleanup'
2 parents a9bf1d0 + e9c4b3a commit c993938

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function deriveClientHints(ua: string): {
5151
mobile: string;
5252
platform: string;
5353
} {
54-
const versionMatch = ua.match(/\bChrome\/(\d+)/);
54+
const versionMatch = /\bChrome\/(\d+)/.exec(ua);
5555
if (!versionMatch) {
5656
throw new Error(
5757
`Invalid MARKFETCH_USER_AGENT=${JSON.stringify(ua)} — expected a Chrome User-Agent containing "Chrome/<version>". Sec-CH-UA-* client hints are derived from this string and would be incoherent otherwise.`,
@@ -339,14 +339,14 @@ function extractArticle(
339339
const decoded = decodeEncodedCodeTags(html);
340340
const withBase = ensureBaseHref(decoded, url);
341341
const { document } = parseHTML(withBase);
342-
rewriteForReadability(document as unknown as Document);
342+
rewriteForReadability(document);
343343
// keepClasses: true preserves `class="language-X"` on <code> elements so
344344
// turndown's default fenced-code rule can emit the language hint after the
345345
// opening fence. Default Readability strips all classes except "page".
346346
// Other class attributes that survive (`headerlink`, etc.) are already
347347
// handled by our pre-Readability rewrites or are inert in turndown's
348348
// output, so this flag is safe in the observed corpus.
349-
const article = new Readability(document as unknown as Document, {
349+
const article = new Readability(document, {
350350
keepClasses: true,
351351
}).parse();
352352
if (!article?.content?.trim()) return null;

tests/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ test("CLI: -o <absolute-path> writes file, prints confirmation to stdout", async
143143
// Confirmation byte count must equal on-disk size (regression-guard
144144
// mirroring server.test.ts T2: catches anyone replacing Buffer.byteLength
145145
// with markdown.length).
146-
const match = stdout.match(/^Saved (\d+) bytes to /);
146+
const match = /^Saved (\d+) bytes to /.exec(stdout);
147147
assert.ok(match);
148148
const reported = Number(match![1]);
149149
const onDiskSize = (await stat(savePath)).size;

tests/server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ test("savePath multibyte: confirmation byte count === stat(file).size", async ()
556556
});
557557
assert.equal(result.isError, false);
558558
const text = textOf(result);
559-
const match = text.match(/^Saved (\d+) bytes to /);
559+
const match = /^Saved (\d+) bytes to /.exec(text);
560560
assert.ok(match, `confirmation must declare a byte count: got ${text}`);
561561
const reportedBytes = Number(match[1]);
562562
const onDisk = await stat(savePath);

0 commit comments

Comments
 (0)