Skip to content

Commit 4407994

Browse files
authored
feat: Allow digits as slug's first character (#4647)
We used to forbid digits as an instance slug's first character probably because of limitations in CouchDB. Now that we use prefixes for our databases names we probably don't need this check which is pretty limitating when it comes to using data from third-party SSOs for example.
2 parents 362b7cb + 094e081 commit 4407994

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎model/instance/lifecycle/helpers.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func checkAliases(inst *instance.Instance, aliases []string) ([]string, error) {
161161
}
162162

163163
const illegalChars = " /,;&?#@|='\"\t\r\n\x00"
164-
const illegalFirstChars = "0123456789."
164+
const illegalFirstChars = "."
165165

166166
func validateDomain(domain string) (string, error) {
167167
var err error

‎model/instance/lifecycle/lifecycle_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func TestLifecycle(t *testing.T) {
8888
assert.NotEmpty(t, instance.ID())
8989
assert.Equal(t, instance.Domain, "test.cozycloud.cc")
9090
}
91+
92+
_, err = lifecycle.Create(&lifecycle.Options{
93+
Domain: "1test.cozycloud.cc",
94+
Locale: "en",
95+
})
96+
assert.NoError(t, err)
9197
})
9298

9399
t.Run("CreateInstanceWithFewSettings", func(t *testing.T) {
@@ -169,6 +175,12 @@ func TestLifecycle(t *testing.T) {
169175
Locale: "en",
170176
})
171177
assert.Error(t, err, "An error is expected")
178+
179+
_, err = lifecycle.Create(&lifecycle.Options{
180+
Domain: ".foo.cozycloud.cc",
181+
Locale: "en",
182+
})
183+
assert.Error(t, err, "An error is expected")
172184
})
173185

174186
t.Run("GetWrongInstance", func(t *testing.T) {

0 commit comments

Comments
 (0)