Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Doesn't support arrays of paths since Express 4.16.4, "Pipe character bug fix" #4

Open
Mattsi-Jansky opened this issue May 13, 2019 · 3 comments

Comments

@Mattsi-Jansky
Copy link

Since Express 4.x it has been valid syntax to use an array for a path, ie app.get(['/','/login'], ...). Since the pipe character bug fix was added in 0.0.7 this results in the following bug when the connect-datadog middleware gets called:

TypeError: str.replace is not a function
    at replacePipeChar (/usr/src/app/node_modules/connect-datadog/lib/index.js:27:21)
    at ServerResponse.res.end (/usr/src/app/node_modules/connect-datadog/lib/index.js:46:39)
    at ServerResponse.send (/usr/src/app/node_modules/express/lib/response.js:221:10)

It fails in the replacePipeChar function because it assumes that req.route.path will be a string, but it is actually an an array.

@rochdev
Copy link
Member

rochdev commented Jul 4, 2019

Given the nature of the change, this will not be an easy fix. We need a way to find out which of the routes in the array was matched and this means quite a big change to the library.

In the meantime, it should be possible to work around the issue by splitting the app.get in 2 different calls. For example:

app.use('/', login)
app.use('/login', login)

@amirzahavi
Copy link

+1

1 similar comment
@mdita
Copy link

mdita commented Aug 4, 2020

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants