Skip to content

Commit 41e2076

Browse files
lcawlsethmlarson
andauthored
Remove trailing slashes in paths with a warning
Co-authored-by: Seth Michael Larson <[email protected]>
1 parent 1ad7fe3 commit 41e2076

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

compiler/src/steps/validate-model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
234234

235235
const urlProperties = new Set<string>()
236236
for (const url of endpoint.urls) {
237+
// Strip trailing slashes from paths
238+
if (url.path !== '/' && url.path.endsWith('/')) {
239+
modelError(`Url path '${url.path}' has a trailing slash`)
240+
url.path = url.path.replace(/\/$/, '')
241+
}
242+
237243
const re = /{([^}]+)}/g
238244
let m
239245
while ((m = re.exec(url.path)) != null) { // eslint-disable-line no-cond-assign

output/schema/schema.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/validation-errors.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)