Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installation names including "." character #119

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion claim/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Claim struct {
}

// ValidName is a regular expression that indicates whether a name is a valid claim name.
var ValidName = regexp.MustCompile("^[a-zA-Z0-9_-]+$")
var ValidName = regexp.MustCompile("^[a-zA-Z0-9._-]+$")

// New creates a new Claim initialized for an installation operation.
func New(name string) (*Claim, error) {
Expand Down
13 changes: 9 additions & 4 deletions claim/claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,23 @@ func TestUpdate(t *testing.T) {
}

func TestValidName(t *testing.T) {
is := assert.New(t)

for name, expect := range map[string]bool{
"M4cb3th": true,
"Lady MacBeth": false, //spaces illegal
"Lady MacBeth": false, // spaces illegal
"3_Witches": true,
"Banquø": false, // We could probably loosen this one up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but ø is part of L and here it isn't approved. Group S is spacing and is also approved. In fact, the only group that seems to not be allowed here is C so none of the tests here should fail. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that note, my understanding is that, if you are using regex (and thus re2) you can get away using unicode character classes explicitly and probably get away with [\pL\pM\pN\pP\pS\pZ]* or so...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a new issue for this, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #126

"King-Duncan": true,
"MacDuff@geocities.com": false,
"hecate": true, // I wouldn't dare cross Hecate.
"foo bar baz": false,
"foo.bar.baz": true,
"foo-bar-baz": true,
"foo_bar_baz": true,
"": false,
} {
is.Equal(expect, ValidName.MatchString(name))
t.Run(name, func(t *testing.T) {
assert.Equal(t, expect, ValidName.MatchString(name), "expected '%s' to be %t", name, expect)
})
}
}

Expand Down