Skip to content

fix(lexver): parsePrefix output should always be a string-prefix of parseVersion#22

Merged
coolaj86 merged 2 commits into
mainfrom
fix-parsePrefix-with-release-suffix
May 8, 2026
Merged

fix(lexver): parsePrefix output should always be a string-prefix of parseVersion#22
coolaj86 merged 2 commits into
mainfrom
fix-parsePrefix-with-release-suffix

Conversation

@coolaj86

@coolaj86 coolaj86 commented May 8, 2026

Copy link
Copy Markdown
Member

parsePrefix(v) must always be a string-prefix of parseVersion(v)matchSorted uses startsWith. The invariant breaks when the input has a release suffix because parsePrefix skips zero-padding while parseVersion pads:

parseVersion('1.0.0-beta')  // '0001.0000.0000.0000-beta'
parsePrefix('1.0.0-beta')   //         '0001.0000.0000-beta'   ← not a prefix

Fix: when there's a release suffix, treat the input as a complete version (not a partial prefix) — pad to 4 digit components before appending the suffix. Partial inputs like 1.0 still skip padding.

Verified for 1.0.0-beta, 2025.11.15-15.42.45, 1.991, 1.0, v1.991.1+hotfix1 — all satisfy the invariant. Existing lexver-test.js still passes.

…arseVersion

When the input has a release suffix (e.g. '1.0.0-beta',
'2025.11.15-15.42.45'), parsePrefix was skipping zero-padding the digit
components even though parseVersion pads. The result was a string that
didn't string-prefix-match the corresponding lexver:

    parseVersion('1.0.0-beta')  // '0001.0000.0000.0000-beta'
    parsePrefix('1.0.0-beta')   //         '0001.0000.0000-beta'  (mismatch)

This broke matchSorted's prefix-search for any user-supplied complete
version with a prerelease or build suffix — e.g.
'webi <pkg>@2025.11.15-15.42.45' would silently return no matches.

Fix: when there's a release suffix, treat the input as a complete
reference and pad digits to 4 components before appending the suffix.
Partial inputs without a suffix (e.g. '1.0' to match '0001.0000.x.y')
still skip padding as before.
@coolaj86 coolaj86 force-pushed the fix-parsePrefix-with-release-suffix branch from c2ecf80 to 44a9a89 Compare May 8, 2026 03:35
coolaj86 added a commit to webinstall/webi-installers that referenced this pull request May 8, 2026
Brings in webinstall/webi-build-classifier#22 — Lexver.parsePrefix now
produces a true string-prefix of parseVersion when the input has a
release suffix (e.g. '1.0.0-beta', '2025.11.15-15.42.45').

Effect: '/api/installers/<pkg>@<exact-prerelease-or-date-version>.sh'
queries now resolve correctly. Unblocks the zig.vim alias chain, which
redirects through 'vim-zig@2025.11.15-15.42.45' at install time.
@coolaj86 coolaj86 merged commit 9f87804 into main May 8, 2026
3 checks passed
@coolaj86 coolaj86 deleted the fix-parsePrefix-with-release-suffix branch May 8, 2026 04:04
coolaj86 added a commit to webinstall/webi-installers that referenced this pull request May 8, 2026
Lexver.parsePrefix now produces a true string-prefix of parseVersion
when the input has a release suffix (e.g. '1.0.0-beta',
'2025.11.15-15.42.45'). Unblocks pinned-version queries with a
non-trivial release suffix, including the 'webi zig.vim' alias chain
which redirects through 'vim-zig@2025.11.15-15.42.45' at install time.

See webinstall/webi-build-classifier#22.
coolaj86 added a commit to webinstall/webi-installers that referenced this pull request May 8, 2026
Lexver.parsePrefix now produces a true string-prefix of parseVersion
when the input has a release suffix (e.g. '1.0.0-beta',
'2025.11.15-15.42.45'). Unblocks pinned-version queries with a
non-trivial release suffix, including the 'webi zig.vim' alias chain
which redirects through 'vim-zig@2025.11.15-15.42.45' at install time.

See webinstall/webi-build-classifier#22.
coolaj86 added a commit to webinstall/webi-installers that referenced this pull request May 8, 2026
Lexver.parsePrefix now produces a true string-prefix of parseVersion
when the input has a release suffix (e.g. '1.0.0-beta',
'2025.11.15-15.42.45'). Unblocks pinned-version queries with a
non-trivial release suffix, including the 'webi zig.vim' alias chain
which redirects through 'vim-zig@2025.11.15-15.42.45' at install time.

See webinstall/webi-build-classifier#22.
coolaj86 added a commit to webinstall/webi-installers that referenced this pull request May 8, 2026
Lexver.parsePrefix now produces a true string-prefix of parseVersion
when the input has a release suffix (e.g. '1.0.0-beta',
'2025.11.15-15.42.45'). Unblocks pinned-version queries with a
non-trivial release suffix, including the 'webi zig.vim' alias chain
which redirects through 'vim-zig@2025.11.15-15.42.45' at install time.

See webinstall/webi-build-classifier#22.
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.

1 participant