Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug when the route is a Null string #48

Closed

Conversation

ShangguanQuail
Copy link

@ShangguanQuail ShangguanQuail commented Dec 11, 2017

I got an error message when I use like this:

// With express-promise-router
var router = require('express-promise-router')();

router.use('', function (req, res) {
    return Promise.reject();
})

this is the error message:

/express-promise-router/lib/express-promise-router.js:81
                ((Array.isArray(args[0]) && 'string' === typeof args[0][0]) || args[0][0] instanceof RegExp)
                                                                                      ^

TypeError: Cannot read property '0' of undefined

Yeah, the original url is a Null string, though it‘s not standard.

@mormahr mormahr self-assigned this Dec 13, 2017
@mormahr
Copy link
Member

mormahr commented Dec 13, 2017

I'm pretty busy right now. I'll probably look into this around Christmas.

Thanks for your contribution!

@mormahr
Copy link
Member

mormahr commented Jan 16, 2018

Hi there!

Sorry for keeping you waiting! I' tried to reproduce you're problem with the current release version but wasn't able to. From the line number it seems like you're using an outdated version (1.1.1?). I checked out v1.1.1 and tried to reproduce it without any luck.

var app = require('express')();
var router = require('./lib/express-promise-router')();

router.use('', function (req, res) {
    return Promise.reject();
})

app.use(router);
app.listen(1204)

I used this sample code and it correctly set the route for '/' even though only '' was given. I used express@4.16.2 and for this and express-promise-router@1.1.1 as well as express-promise-router@2.0.0. Maybe you can provide a full example repository that reproduces your problem.

Thank you for your patience!
Moritz

@mormahr
Copy link
Member

mormahr commented Jun 1, 2018

As this has been inactive for a few month i'm closing it. Feel free to comment if something has changed and / or your problem persists.

@mormahr mormahr closed this Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants