Merge pull request #19473 from Homebrew/cask-token

cask/utils: alllow use of @ in cask name
This commit is contained in:
Patrick Linnane 2025-03-12 14:57:23 +00:00 committed by GitHub
commit 319e7b8949
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -111,9 +111,8 @@ module Cask
def self.token_from(name)
name.downcase
.gsub("+", "-plus-")
.gsub("@", "-at-")
.gsub(/[ _·•]/, "-")
.gsub(/[^\w-]/, "")
.gsub(/[^\w@-]/, "")
.gsub(/--+/, "-")
.delete_prefix("-")
.delete_suffix("-")

View File

@ -17,7 +17,12 @@ RSpec.describe Homebrew::DevCmd::Create do
end
it "generates valid cask tokens" do
t = Cask::Utils.token_from("A Foo@Bar_Baz++!")
expect(t).to eq("a-foo-at-bar-baz-plus-plus")
t = Cask::Utils.token_from("A FooBar_Baz++!")
expect(t).to eq("a-foobar-baz-plus-plus")
end
it "retains @ in cask tokens" do
t = Cask::Utils.token_from("test@preview")
expect(t).to eq("test@preview")
end
end