Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(semver): throw on invalid input in parseRange() #5567

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Jul 29, 2024

Closes #4845

@iuioiua iuioiua requested a review from kt3k as a code owner July 29, 2024 08:08
import { isSemVer } from "./is_semver.ts";

function isComparator(value: unknown): value is Comparator {
if (
value === null || value === undefined || Array.isArray(value) ||
typeof value !== "object"
) return false;
if (value === NONE || value === ALL) return true;
if (value === ALL) return true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, we no longer regard <0.0.0 as a valid comparator.

// remove spaces between operators and versions
.replaceAll(/(?<=<|>|=|~) +/g, "")
.replaceAll(/(?<=<|>|=|~)(\s+)/g, "")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pass-by fix that this change requires.

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.48%. Comparing base (606838b) to head (4fd8b84).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5567      +/-   ##
==========================================
+ Coverage   96.12%   96.48%   +0.36%     
==========================================
  Files         465      465              
  Lines       37772    37770       -2     
  Branches     5549     5582      +33     
==========================================
+ Hits        36308    36443     +135     
+ Misses       1422     1285     -137     
  Partials       42       42              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

semver/parse_range.ts Outdated Show resolved Hide resolved
@iuioiua iuioiua requested a review from kt3k July 29, 2024 23:43
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@iuioiua iuioiua merged commit 3a44653 into main Jul 30, 2024
13 checks passed
@iuioiua iuioiua deleted the semver-throw-parseRange branch July 30, 2024 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

semver: parseRange doesn't throw with invalid input
2 participants