Skip to content

[Bug] createWildcardRegex invalid regular expression #405 and link checker #401 - #402

Merged
nev21 merged 1 commit into
mainfrom
nev21/PrepareRelease
Apr 16, 2025
Merged

nev21 merged 1 commit into
mainfrom
nev21/PrepareRelease

Conversation

@nev21

@nev21 nev21 commented Apr 15, 2025 •

Copy link
Copy Markdown
Contributor

[Bug] createWildcardRegex has an invalid regular expression #405
[Task] Add pre-release testing validation with external projects #401

  • Add simple readme link checker

Copilot AI review requested due to automatic review settings April 15, 2025 07:14
@nev21
nev21 requested a review from a team as a code owner April 15, 2025 07:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (1)

lib/test/readme-links-check.js:1

  • [nitpick] Consider removing or updating the hard-coded file path in the file header comment to avoid confusion when used in different environments.
// filepath: d:\gith1\tsUtils\lib\test\readme-links-check.js

// Configuration
const readmePath = path.resolve(__dirname, '../../README.md');
const docsBasePath = path.resolve(__dirname, '../../docs');
const baseUrl = 'https://nevware21.github.io/ts-utils/typedoc/';

Check failure

Code scanning / CodeQL

Incomplete regular expression for hostnames

This string, which is used as a regular expression [here](1), has an unescaped '.' before 'github.io/ts-utils/typedoc/', so it might match more hosts than expected.

Copilot Autofix

AI over 1 year ago

To fix the problem, we need to ensure that the . characters in the baseUrl string are properly escaped when constructing the regular expression. This will prevent the regular expression from matching unintended hosts.

  • Update the baseUrl string to escape the . characters.
  • Modify the regular expression construction to use the updated baseUrl.
Suggested changeset 1
lib/test/readme-links-check.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/lib/test/readme-links-check.js b/lib/test/readme-links-check.js
--- a/lib/test/readme-links-check.js
+++ b/lib/test/readme-links-check.js
@@ -7,3 +7,3 @@
 const docsBasePath = path.resolve(__dirname, '../../docs');
-const baseUrl = 'https://nevware21.github.io/ts-utils/typedoc/';
+const baseUrl = 'https://nevware21\\.github\\.io/ts-utils/typedoc/';
 
@@ -23,3 +23,3 @@
 // Extract all links that start with the baseUrl
-const linkRegex = new RegExp(`(${baseUrl.replace(/\//g, '\\/').replace(/\./g, '\\.')}[^\\)"'\\s]+)`, 'g');
+const linkRegex = new RegExp(`(${baseUrl.replace(/\//g, '\\/')}[^\\)"'\\s]+)`, 'g');
 let match;
EOF
@@ -7,3 +7,3 @@
const docsBasePath = path.resolve(__dirname, '../../docs');
const baseUrl = 'https://nevware21.github.io/ts-utils/typedoc/';
const baseUrl = 'https://nevware21\\.github\\.io/ts-utils/typedoc/';

@@ -23,3 +23,3 @@
// Extract all links that start with the baseUrl
const linkRegex = new RegExp(`(${baseUrl.replace(/\//g, '\\/').replace(/\./g, '\\.')}[^\\)"'\\s]+)`, 'g');
const linkRegex = new RegExp(`(${baseUrl.replace(/\//g, '\\/')}[^\\)"'\\s]+)`, 'g');
let match;
Copilot is powered by AI and may make mistakes. Always verify output.
@nev21 nev21 committed this autofix suggestion over 1 year ago.
Comment thread lib/test/readme-links-check.js Fixed
Comment thread lib/test/readme-links-check.js Fixed
@codecov

codecov Bot commented Apr 15, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.72%. Comparing base (eb00ee9) to head (270c2c4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #402   +/-   ##
=======================================
  Coverage   97.72%   97.72%           
=======================================
  Files         115      115           
  Lines        2946     2946           
  Branches      603      604    +1     
=======================================
  Hits         2879     2879           
  Misses         67       67           
Files with missing lines Coverage Δ
lib/src/helpers/regexp.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread lib/test/readme-links-check.js Fixed
@nev21
nev21 force-pushed the nev21/PrepareRelease branch from c7b1857 to ffd1063 Compare April 16, 2025 05:31
@nev21 nev21 added this to the 0.12.2 milestone Apr 16, 2025
[Task] Add pre-release testing validation with external projects #401
- Add simple readme link checker
@nev21
nev21 force-pushed the nev21/PrepareRelease branch from ffd1063 to 270c2c4 Compare April 16, 2025 06:01
@nev21 nev21 changed the title [Task] Add pre-release testing validation with external projects #401 [Bug] createWildcardRegex invalid regular expression #405 and link checker #401 Apr 16, 2025
@nev21
nev21 merged commit 1dfe3a5 into main Apr 16, 2025
@nev21
nev21 deleted the nev21/PrepareRelease branch April 16, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants