From 26cb735c57d8cb917b75f2b82402c2dbc0fa1254 Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Mon, 26 Mar 2018 10:22:49 -0700 Subject: [PATCH] docs(server): document ignoreTrailingSlash --- docs/_api/server.md | 4 ++++ docs/guides/6to7guide.md | 6 ++++++ lib/index.js | 2 ++ lib/router.js | 4 ++-- lib/server.js | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/_api/server.md b/docs/_api/server.md index f6ea00e8f..93a352cb8 100644 --- a/docs/_api/server.md +++ b/docs/_api/server.md @@ -73,6 +73,8 @@ routes and handlers for incoming requests. ciphers; however these can all be specified on httpsServerOptions. - `options.strictRouting` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If set, Restify will treat "/foo" and "/foo/" as different paths. (optional, default `false`) + - `options.ignoreTrailingSlash` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** ignore trailing slash + on paths (optional, default `false`) **Examples** @@ -133,6 +135,8 @@ Creates a new Server. ciphers; however these can all be specified on httpsServerOptions. - `options.noWriteContinue` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** prevents `res.writeContinue()` in `server.on('checkContinue')` when proxing (optional, default `false`) + - `options.ignoreTrailingSlash` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** ignore trailing slash + on paths (optional, default `false`) **Examples** diff --git a/docs/guides/6to7guide.md b/docs/guides/6to7guide.md index b6b6679ac..5f3530047 100644 --- a/docs/guides/6to7guide.md +++ b/docs/guides/6to7guide.md @@ -25,6 +25,12 @@ The new version of restify never returns `RequestAbortedError`. Option `strictRouting` is removed `createServer({ strictRouting: false })`. Strict routing is the new default. +### Path trailing slash at the end + +`/path` and `/path/` are not the same thing in restify `v7.x`. +Use `ignoreTrailingSlash: true` server option if you don't want to differentiate +them from each other. + ### Different `RegExp` usage in router path and wildcards restify's new router backend diff --git a/lib/index.js b/lib/index.js index 6b01fddca..9f9915eb0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -55,6 +55,8 @@ require('./errorTypes'); * ciphers; however these can all be specified on httpsServerOptions. * @param {Boolean} [options.strictRouting=false] - If set, Restify * will treat "/foo" and "/foo/" as different paths. + * @param {Boolean} [options.ignoreTrailingSlash=false] - ignore trailing slash + * on paths * @example * var restify = require('restify'); * var server = restify.createServer(); diff --git a/lib/router.js b/lib/router.js index 32a280b0e..ed8945639 100644 --- a/lib/router.js +++ b/lib/router.js @@ -33,8 +33,8 @@ var ResourceNotFoundError = errors.ResourceNotFoundError; * @param {Boolean} [options.strictNext=false] - Throws error when next() is * called more than once, enabled onceNext option * @param {Object} [options.registry] - route registry - * @param {Object} [options.ignoreTrailingSlash] - ignore trailing slash on - * paths + * @param {Boolean} [options.ignoreTrailingSlash=false] - ignore trailing slash + * on paths */ function Router(options) { assert.object(options, 'options'); diff --git a/lib/server.js b/lib/server.js index 40de7104e..2a633c95f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -90,6 +90,8 @@ var PROXY_EVENTS = [ * ciphers; however these can all be specified on httpsServerOptions. * @param {Boolean} [options.noWriteContinue=false] - prevents * `res.writeContinue()` in `server.on('checkContinue')` when proxing + * @param {Boolean} [options.ignoreTrailingSlash=false] - ignore trailing slash + * on paths * @example * var restify = require('restify'); * var server = restify.createServer();