Skip to content

Commit

Permalink
Revert sanitization of package name (#7246)
Browse files Browse the repository at this point in the history
I think this was a mistake from the beginning. The specs added after
reverting the patch still pass without the change, and the commit
message reads: "JS: Sanitize spaces in filenames", while there's no
filename involved here whatsoever, just the package name.

This commit reverts c5b1fe6 and
2864404.
  • Loading branch information
deivid-rodriguez authored Jul 26, 2023
1 parent 919af32 commit 40c0d20
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,10 @@ def yarnrc_content
end

def sanitized_package_json_content(content)
updated_content =
content.
content.
gsub(/\{\{[^\}]*?\}\}/, "something"). # {{ nm }} syntax not allowed
gsub(/(?<!\\)\\ /, " "). # escaped whitespace not allowed
gsub(%r{^\s*//.*}, " ") # comments are not allowed

json = JSON.parse(updated_content)
json["name"] = json["name"].delete(" ") if json["name"].is_a?(String)
json.to_json
end

def sanitize_package_name(package_name)
Expand Down
20 changes: 0 additions & 20 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@
end
end

context "with a name that needs sanitizing" do
let(:files) { project_dependency_files("npm6/invalid_name") }

it "updates the files" do
expect { updated_files }.to_not(change { Dir.entries(tmp_path) })
updated_files.each { |f| expect(f).to be_a(Dependabot::DependencyFile) }
expect(updated_files.count).to eq(2)
end
end

context "with multiple dependencies" do
let(:files) { project_dependency_files("npm6_and_yarn/multiple_updates") }

Expand Down Expand Up @@ -1561,16 +1551,6 @@
end
end

context "with a name that needs sanitizing" do
let(:files) { project_dependency_files("npm8/invalid_name") }

it "updates the files" do
expect { updated_files }.to_not(change { Dir.entries(tmp_path) })
updated_files.each { |f| expect(f).to be_a(Dependabot::DependencyFile) }
expect(updated_files.count).to eq(2)
end
end

context "with multiple dependencies" do
let(:files) { project_dependency_files("npm8/multiple_updates") }

Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions npm_and_yarn/spec/fixtures/projects/npm6/invalid_name/package.json

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions npm_and_yarn/spec/fixtures/projects/npm8/invalid_name/package.json

This file was deleted.

0 comments on commit 40c0d20

Please sign in to comment.