-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yarn.lock files sometimes have quotes around keys
We've observed examples of yarn.lock files that wrap their keys in quotes (#281)
- Loading branch information
1 parent
9f224aa
commit 65decbd
Showing
3 changed files
with
615 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,15 @@ | |
* resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.7.tgz#9329b4782a7d6bbd7eef57e11addf91ee3ef1e41" | ||
* integrity sha512-YaxPMGs/XIWtYqrdEOZOCPsVWfEoriXopnsz3/i7apYPXQ3698UFhS6dVT1KN5qOsWmVgw/FOrmQgpRaZayGsw== | ||
* </pre> | ||
* | ||
* It appears that, in some cases, the keys are surrounded by quotes (#281). | ||
* We've observed this in "v1" lock files. For example: | ||
* | ||
* <pre> | ||
* "[email protected]": "integrity" | ||
* "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" | ||
* "resolved" "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz" | ||
* "version" "4.1.1" </pre | ||
* | ||
* The implementation is only as sophisticated as it needs to be and only | ||
* provides the behaviour that I require to determine a ClearlyDefined ID from | ||
|
@@ -223,10 +232,12 @@ private String getHeader() { | |
* | ||
* FIXME Validate that we can assume that the version is surrounded by quotes. | ||
* | ||
* 2023-11-10 sometimes the key is surrounded by quotes (#281) | ||
* | ||
* @return | ||
*/ | ||
public String getVersion() { | ||
var pattern = Pattern.compile("version \"(?<version>[^\"]+)\""); | ||
var pattern = Pattern.compile("(?:version|\"version\") \"(?<version>[^\"]+)\""); | ||
for (Record child : nested) { | ||
var matcher = pattern.matcher(child.value); | ||
if (matcher.matches()) { | ||
|
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
Oops, something went wrong.