Skip to content

Commit 0ade8bc

Browse files
committed
chore: validate path starts with slash
1 parent e3ea900 commit 0ade8bc

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

packages/config-schema/src/schema/netlify-toml.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@
550550
},
551551
"path": {
552552
"type": "string",
553-
"description": "Path pattern to associate with this edge function."
553+
"description": "Path pattern to associate with this edge function.",
554+
"pattern": "^/.*"
554555
}
555556
},
556557
"additionalProperties": false,

packages/config-schema/tests/__snapshots__/schema-tests.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@ exports[`JSON config schema > edge-functions-errors 2`] = `
387387
},
388388
"schemaPath": "#/properties/edge_functions/items/properties/cache/enum",
389389
},
390+
{
391+
"instancePath": "/edge_functions/2/path",
392+
"keyword": "pattern",
393+
"message": "must match pattern \\"^/.*\\"",
394+
"params": {
395+
"pattern": "^/.*",
396+
},
397+
"schemaPath": "#/properties/edge_functions/items/properties/path/pattern",
398+
},
390399
]
391400
`;
392401

packages/config-schema/tests/fixtures/edge-functions-errors/test.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ cache = "notvalid"
66
[[edge_functions]]
77
other = 1
88
cache = 1
9+
10+
[[edge_functions]]
11+
path = "noslash"
12+
function = "foo"

packages/config-schema/tests/fixtures/edge-functions-pass/test.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ function = "injector"
1111
path = "/caching"
1212
cache = "manual"
1313
function = "injector"
14+
15+
[[edge_functions]]
16+
path = "/"
17+
function = "injector"

0 commit comments

Comments
 (0)