Fix bad routing regex for docs & blogs (#795)

* fix bad routing regex for docs & blogs

* extract to routing.js & add test

* add more test case

* address code review

* prettier
This commit is contained in:
Endilie Yacop Sucipto 2018-06-24 14:10:32 +07:00 committed by GitHub
parent 5a8e9a9ff1
commit 66b2033546
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 3 deletions

20
lib/core/routing.js Normal file
View file

@ -0,0 +1,20 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const escapeStringRegexp = require('escape-string-regexp');
function docsRouting(baseUrl) {
return new RegExp(`^${escapeStringRegexp(baseUrl)}docs\/.*html$`);
}
function blogRouting(baseUrl) {
return new RegExp(`^${escapeStringRegexp(baseUrl)}blog\/.*html$`);
}
module.exports = {
docsRouting,
blogRouting,
};