mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-07 06:05:34 +00:00
Update slug validation rules to disallow uppercase
This commit is contained in:
parent
4ccee09f73
commit
ebcb060ece
5 changed files with 10 additions and 9 deletions
hc/api
static/js
templates/front
|
@ -4,7 +4,7 @@ check = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {"type": "string", "maxLength": 100},
|
"name": {"type": "string", "maxLength": 100},
|
||||||
"slug": {"type": "string", "pattern": "^[a-zA-Z0-9-_]*$"},
|
"slug": {"type": "string", "pattern": "^[a-z0-9-_]*$"},
|
||||||
"desc": {"type": "string"},
|
"desc": {"type": "string"},
|
||||||
"tags": {"type": "string", "maxLength": 500},
|
"tags": {"type": "string", "maxLength": 500},
|
||||||
"timeout": {"type": "number", "minimum": 60, "maximum": 31536000},
|
"timeout": {"type": "number", "minimum": 60, "maximum": 31536000},
|
||||||
|
|
|
@ -387,8 +387,9 @@ class CreateCheckTestCase(BaseTestCase):
|
||||||
self.assertEqual(check.slug, "")
|
self.assertEqual(check.slug, "")
|
||||||
|
|
||||||
def test_it_handles_invalid_slug(self):
|
def test_it_handles_invalid_slug(self):
|
||||||
r = self.post({"name": "Foo", "slug": "Hey!"}, v=3)
|
for slug in ["Uppercase", "special!", "look spaces"]:
|
||||||
self.assertEqual(r.status_code, 400)
|
r = self.post({"name": "Foo", "slug": "Hey!"}, v=3)
|
||||||
self.assertEqual(
|
self.assertEqual(r.status_code, 400)
|
||||||
r.json()["error"], "json validation error: slug does not match pattern"
|
self.assertEqual(
|
||||||
)
|
r.json()["error"], "json validation error: slug does not match pattern"
|
||||||
|
)
|
||||||
|
|
|
@ -23,7 +23,7 @@ $(function () {
|
||||||
if (suggested) {
|
if (suggested) {
|
||||||
help.html(`Suggested value: <code>${suggested}</code>`);
|
help.html(`Suggested value: <code>${suggested}</code>`);
|
||||||
} else {
|
} else {
|
||||||
help.text("Allowed characters: a-z, A-Z, 0-9, hyphens, underscores.");
|
help.text("Allowed characters: a-z, 0-9, hyphens, underscores.");
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.attr("disabled", !suggested);
|
btn.attr("disabled", !suggested);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
type="text"
|
type="text"
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
value="{{ check.slug }}"
|
value="{{ check.slug }}"
|
||||||
pattern="[a-zA-Z0-9_-]+"
|
pattern="[a-z0-9_-]+"
|
||||||
class="form-control" />
|
class="form-control" />
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
type="text"
|
type="text"
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
value="{{ check.slug }}"
|
value="{{ check.slug }}"
|
||||||
pattern="[a-zA-Z0-9_-]+"
|
pattern="[a-z0-9_-]+"
|
||||||
data-src-id="update-name-input"
|
data-src-id="update-name-input"
|
||||||
data-btn-id="use-suggested"
|
data-btn-id="use-suggested"
|
||||||
data-preview-id="slug-help"
|
data-preview-id="slug-help"
|
||||||
|
|
Loading…
Add table
Reference in a new issue