uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.76k stars 563 forks source link

res.getQuery(key: string): string returns undefined #917

Closed lortonx closed 1 year ago

lortonx commented 1 year ago

The method returns "undefined" if no query parameters are specified. Tested on websockets. Address example: ws://127.0.0.1:8080 - undefined ws://127.0.0.1:8080?123-123

expected result is an empty string current result - undefined typing - https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L214

version v20.30.0 node version v18.16.0

The version in which it was normal v19.2.0 and node 16.x

uNetworkingAB commented 1 year ago

It's an issue in the typings. It return undefined if there is no such key, while it returns empty string if there is such a key, with empty string as value. So the right typing is undefine | String