Skip to content

Double colons in package names (aliases) are deleted#2

Description

@splattael

Hi 馃憢

The parser drops the : in package names (see aliases).

For example:

File.write("bug.lock", <<~YARN)
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

"@gitlab/vue-router-vue3@npm:vue-router@4.1.6":
  version "4.1.6"
  resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.1.6.tgz#b70303737e12b4814578d21d68d21618469375a1"
  integrity sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==
  dependencies:
    "@vue/devtools-api" "^6.4.5"
YARN

YarnLockParser::Parser.parse("bug.lock")
# => [{:name=>"@gitlab/vue-router-vue3@npmvue-router", :version=>"4.1.6"}]

Proposed solution

Allow : to be part of package names:

diff --git a/lib/yarn_lock_parser.rb b/lib/yarn_lock_parser.rb
index 5cd407a..4caca55 100644
--- a/lib/yarn_lock_parser.rb
+++ b/lib/yarn_lock_parser.rb
@@ -65,7 +65,7 @@ module YarnLockParser
             end
           elsif input[0] == '"'
             chop, val = extract_value(input)
-            tokens << build_token.call(TOKEN_TYPES[:string], val.gsub(/\"|:/, ""))
+            tokens << build_token.call(TOKEN_TYPES[:string], val.gsub(/\"/, ""))
           elsif /^[0-9]/.match?(input)
             val = /^[0-9]+/.match(input).to_s
             chop = val.length
>> YarnLockParser::Parser.parse("bug.lock")
=> [{:name=>"@gitlab/vue-router-vue3@npm:vue-router", :version=>"4.1.6"}]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions