Closed wll8 closed 6 days ago
path-to-regexp@0.2.5
is not a new version.
The version that found the problem was 0.1.10, but this error was thrown in 0.1.11.
if (typeof path !== 'string') {
throw new TypeError('path must be a string, array of strings, or regular expression');
}
imgA:
imgB:
In imgA, httpolyglot passed an object, which was concatenated into a string in path-to-regexp 0.1.7, and the program had no errors. However, in later versions of path-to-regexp, my use case ran into errors because the object could not be handled "friendly".
Unfortunately, httpolyglot does not accept questions. What should I do? Can path-to-regexp retain the old behavior and ignore it without reporting an error when a non-string is passed in, or something else?
I won't be fixing this in path-to-regexp
because this library was never intended to accept random objects as input. This appears to be a bug in httpolyglot
, since bind
has always been a HTTP method on that function and was not the native JS bind
.
It's a regrettable situation, but it appears that line never did what the authors intended (when combined with Express) and could be removed. I'd maybe suggest a PR removing this line: https://github.com/httptoolkit/httpolyglot/blob/8f726e1fce599b7a1444444cab396e818306c5b0/src/index.ts#L81
Alternatively if you write a wrapper function that has a real bind
method, that would work too. E.g. (req, res) => app(req, res);
.
The new version of path-to-regexp is an incompatible update