-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: redefine hostname as a required property that maps to --host (#…
…256)
- Loading branch information
1 parent
f6d5837
commit 13a2158
Showing
21 changed files
with
386 additions
and
300 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package stringutil | ||
|
||
import "regexp" | ||
|
||
func SanitizeID(id string) string { | ||
reg := regexp.MustCompile(`[^a-zA-Z0-9_\-\.]+`) | ||
return reg.ReplaceAllString(id, "_") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package stringutil | ||
|
||
import "testing" | ||
|
||
func TestSanitizeID(t *testing.T) { | ||
tcs := []struct { | ||
name string | ||
id string | ||
want string | ||
}{ | ||
{ | ||
name: "empty", | ||
id: "", | ||
want: "", | ||
}, | ||
{ | ||
name: "no change", | ||
id: "abc123", | ||
want: "abc123", | ||
}, | ||
{ | ||
name: "spaces", | ||
id: "a b c 1 2 3", | ||
want: "a_b_c_1_2_3", | ||
}, | ||
{ | ||
name: "special characters", | ||
id: "a!b@c#1$2%3", | ||
want: "a_b_c_1_2_3", | ||
}, | ||
{ | ||
name: "unicode", | ||
id: "a👍b👍c👍1👍2👍3", | ||
want: "a_b_c_1_2_3", | ||
}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := SanitizeID(tc.id) | ||
if got != tc.want { | ||
t.Errorf("SanitizeID(%q) = %q, want %q", tc.id, got, tc.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.