Skip to content

Commit 68970a0

Browse files
Алексей КолгановАлексей Колганов
authored andcommitted
[add] optional "useTrailingSlashes" option
1 parent 59edf4f commit 68970a0

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

doc/readme-options.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,10 @@ Optional
248248

249249
A string that defines and enables the options fallback.
250250
This allows you to define a fallback for every options call except there is one defined for the affected endpoint.
251+
252+
253+
#### options.useTrailingSlashes
254+
Type: `Boolean`
255+
Optional
256+
257+
A boolean to decide to use trailing slashes in URL if your endpoints always ending with it.

lib/controller/AppController.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ AppController.prototype = extend(AppController.prototype, {
4242
* @param {string} options.privateKey
4343
* @param {string} options.certificate
4444
* @param {boolean} options.open
45+
* @param {boolean} options.useTrailingSlashes
4546
* @param {string|undefined} options.jsVersion
4647
* @public
4748
*/

lib/controller/MockController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ MockController.prototype = extend(MockController.prototype, {
392392
/**
393393
* @method _processOptionsFallback
394394
* @param {Object} req is the original request
395-
* @param {String} directory for the response
395+
* @param {String} dir directory for the response
396396
* @param {Object} options
397397
* @returns {String}
398398
* @private
@@ -737,7 +737,7 @@ MockController.prototype = extend(MockController.prototype, {
737737
path = path.split('?')[0];
738738

739739
// removing trailing slashes to make it work on windows
740-
if (path.slice(-1) === '/') {
740+
if (!options.useTrailingSlashes && path.slice(-1) === '/') {
741741
path = path.slice(0, -1);
742742
}
743743

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)