Skip to content

Commit

Permalink
fix(parse): Allow hyphens in usernames and dataset names
Browse files Browse the repository at this point in the history
  • Loading branch information
dustmop authored and b5 committed Apr 13, 2020
1 parent 3406c8a commit c3b616a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/fsi_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestInitBadName(t *testing.T) {
_ = run.CreateAndChdirToWorkDir("invalid_dataset_name")

// Init with an invalid dataset name
err := run.ExecCommand("qri init --name invalid-dataset-name --format csv")
err := run.ExecCommand("qri init --name invalid=dataset=name --format csv")
if err == nil {
t.Fatal("expected error trying to init, did not get an error")
}
Expand Down
4 changes: 2 additions & 2 deletions dsref/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
// /ipfs/QmSome1Commit2Hash3

const (
alphaNumeric = `[a-zA-Z]\w*`
alphaNumericDsname = `[a-zA-Z]\w{0,143}`
alphaNumeric = `[a-zA-Z][\w-]*`
alphaNumericDsname = `[a-zA-Z][\w-]{0,143}`
b58Id = `Qm[0-9a-zA-Z]{0,44}`
)

Expand Down
4 changes: 4 additions & 0 deletions dsref/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func TestParse(t *testing.T) {
{"right hand side", "@QmFirst/ipfs/QmSecond", Ref{ProfileID: "QmFirst", Path: "/ipfs/QmSecond"}},
{"just path", "@/ipfs/QmSecond", Ref{Path: "/ipfs/QmSecond"}},
{"long name", "peer/some_name@/map/QmXATayrFgsS3tpCi2ykfpNJ8uiCWT74dttnvJvVo1J7Rn", Ref{Username: "peer", Name: "some_name", Path: "/map/QmXATayrFgsS3tpCi2ykfpNJ8uiCWT74dttnvJvVo1J7Rn"}},
{"name-has-dash", "abc/my-dataset", Ref{Username: "abc", Name: "my-dataset"}},
{"dash-in-username", "some-user/my_dataset", Ref{Username: "some-user", Name: "my_dataset"}},
}
for i, c := range goodCases {
ref, err := Parse(c.text)
Expand All @@ -41,6 +43,8 @@ func TestParse(t *testing.T) {
{"local filename", "foo.json", "parsing ref, unexpected character at position 0: 'f'"},
{"absolute filepath", "/usr/local/bin/file.cbor", "parsing ref, unexpected character at position 0: '/'"},
{"absolute dirname", "/usr/local/bin", "parsing ref, unexpected character at position 0: '/'"},
{"dot in dataset", "abc/data.set", "parsing ref, unexpected character at position 8: '.'"},
{"equals in dataset", "abc/my=ds", "parsing ref, unexpected character at position 6: '='"},
}
for i, c := range badCases {
_, err := Parse(c.text)
Expand Down

0 comments on commit c3b616a

Please sign in to comment.