-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filter out non-JSON API resources
- Loading branch information
Mateu Aguiló Bosch
committed
Jun 17, 2018
1 parent
ea982dd
commit e44014e
Showing
12 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @flow | ||
|
||
/** | ||
* Takes a list of paths in Open API format and makes them into regexps. | ||
* | ||
* @param {string[]} paths | ||
* The Open API paths. | ||
* | ||
* @return {string[]} | ||
* The list of strings ready to feed a RegExp. | ||
*/ | ||
module.exports = (paths: Array<string>): Array<string> => | ||
paths | ||
.map(p => p.replace('/', '\\/').replace(/{[^{}/]+}/g, '[^\\/]+')) | ||
.map(p => `^${p}/?$`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const openApiPathToRegExp = require('./openApiPathToRegExp'); | ||
|
||
describe('openApiPathToRegExp', () => { | ||
test('It can transform paths', () => { | ||
expect.assertions(1); | ||
const paths = ['/foo', '/foo/{bar}', '/foo/{bar}/oof/{baz}']; | ||
const actual = openApiPathToRegExp(paths); | ||
const expected = [ | ||
'^\\/foo/?$', | ||
'^\\/foo/[^\\/]+/?$', | ||
'^\\/foo/[^\\/]+/oof/[^\\/]+/?$', | ||
]; | ||
expect(actual).toEqual(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters