Skip to content

Commit cf093f1

Browse files
davidnghk01gergelyke
authored andcommitted
fix(routes): option to make route matching case insensitive #124 (#125)
1 parent eec7b9f commit cf093f1

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

lib/terminus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function decorateWithHealthCheck (server, state, options) {
6565
server.listeners('request').forEach((listener) => {
6666
server.removeListener('request', listener)
6767
server.on('request', async (req, res) => {
68-
const url = caseInsensitive ? req.url : req.url.toLowerCase()
68+
const url = caseInsensitive ? req.url.toLowerCase() : req.url
6969
const healthCheck = healthChecks[url]
7070
if (healthCheck) {
7171
if (state.isShuttingDown) {

lib/terminus.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ describe('Terminus', () => {
8484
expect(onHealthCheckRan).to.eql(true)
8585
})
8686

87+
it('case insensitive opt-in - should working with original path', async () => {
88+
let onHealthCheckRan = false
89+
90+
createTerminus(server, {
91+
healthChecks: {
92+
'/healthCheck': () => {
93+
onHealthCheckRan = true
94+
return Promise.resolve()
95+
}
96+
},
97+
caseInsensitive: true
98+
})
99+
server.listen(8000)
100+
101+
await fetch('http://localhost:8000/healthCheck')
102+
expect(onHealthCheckRan).to.eql(true)
103+
})
104+
87105
it('includes info on resolve', async () => {
88106
let onHealthCheckRan = false
89107

package-lock.json

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

0 commit comments

Comments
 (0)