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

Coerce from right-to-left #248

Closed
marceloavf opened this issue Jul 20, 2018 · 3 comments
Closed

Coerce from right-to-left #248

marceloavf opened this issue Jul 20, 2018 · 3 comments

Comments

@marceloavf
Copy link

marceloavf commented Jul 20, 2018

By default, coerce runs from left-to-right returning the version, I would discuss if it should be possible to have an option to check from right-to-left.

Actual example:

semver.coerce('test/v1.0.0/app-v1.2.3-install.exe')
//=> version: "1.0.0"

Possibility

semver.coerce('test/v1.0.0/app-v1.2.3-install.exe', 'right-to-left')
//=> version: "1.2.3"
@isaacs
Copy link
Contributor

isaacs commented Jul 1, 2019

I'd avoid a magic string in the API, and we already accept an options object as the second argument. How about coerce(string, { rtl: true })?

@marceloavf
Copy link
Author

Would be nice @isaacs

@isaacs isaacs closed this as completed in 388ec1c Jul 1, 2019
@isaacs
Copy link
Contributor

isaacs commented Jul 1, 2019

Landed on 6.2.0. Turned out to be an interesting little algorithm! You don't want 1.2.3.4 to coerce to 4.0.0 in rtl mode. I'd expect 2.3.4 in that case. I think what I landed on is reasonably efficient and does the right thing.

stabbylambda pushed a commit to stabbylambda/node-semver that referenced this issue Nov 18, 2019
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

No branches or pull requests

2 participants