-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added number support to version text formatter (#1620)
- Loading branch information
1 parent
16eea6d
commit 1dff491
Showing
2 changed files
with
3 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1dff491
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about 0.10?
1dff491
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JSON, 0.10 can’t be represented as a number. It would need to be a string.
1dff491
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. That's why taking number as an argument makes no sense. Even if you argue that version can be a number (most software I know uses string however), it shouldn't be floating point number.
That' just another dirty hack. Why not just require string?
1dff491
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's more... According to JSON spec, limits on the range and precision of numbers accepted is an implementation detail (https://tools.ietf.org/html/rfc7159#section-6).
It's not like 0.10 can't be represented as a number in JSON. It could be. It can't be represented as a Number in JS runtime (it's represented approximately using IEEE 754; and it's also indistinguishable from 0.1).
You will do whatever you wan't. I just believe it's not very safe to allow numbers here and decided to let you know.