Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default defineConfig([

"n/no-unsupported-features/node-builtins": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-extraneous-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-deprecated-api": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-deprecated-api": "error",
"n/no-unpublished-import": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/no-process-exit": "off", // https://github.com/eclipse-thingweb/node-wot/issues/1430
"n/hashbang": "warn",
Expand Down
7 changes: 5 additions & 2 deletions packages/binding-coap/src/coap-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default class CoapClient implements ProtocolClient {
public setSecurity = (metadata: Array<SecurityScheme>): boolean => true;

private uriToOptions(uri: string): CoapRequestParams {
const requestUri = url.parse(uri);
const requestUri = new url.URL(uri);
const agentOptions = this.agentOptions;
agentOptions.type = net.isIPv6(requestUri.hostname ?? "") ? "udp6" : "udp4";
this.agent = new Agent(agentOptions);
Expand All @@ -219,7 +219,10 @@ export default class CoapClient implements ProtocolClient {
hostname: requestUri.hostname ?? "",
port: requestUri.port != null ? parseInt(requestUri.port, 10) : 5683,
pathname: requestUri.pathname ?? "",
query: requestUri.query ?? "",
query:
requestUri.search && requestUri.search.length > 0 && requestUri.search[0] === "?"
? requestUri.search.substring(1)
: "",
Comment on lines +222 to +225
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit clumsy since requestUri.search has a leading ? while the old requestUri.query did not have it

?v=6xJ
vs
v=6xJ

@JKRhb please have a look

Copy link
Member

@JKRhb JKRhb Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I ran into similar problems a lot time ago, also in node-coap :/ Unfortunately, the URL API is really awful IIRC, both when it comes to query parameters and handling IPv6 addresses. In some aspects, it is also not compliant with RFC 3986 if I am not mistaken, which is one reason I didn't transition to the URL API back in the day.

If I hopefully find the time, I will take a closer look at this PR later this week

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw that the goals of the "URL standard" include the following:

Align RFC 3986 and RFC 3987 with contemporary implementations and obsolete the RFCs in the process.

That contributes to quite a frustrating experience when working with "proper" URIs using this API. Therefore, we might need to consider using a different implementation here instead (maybe fast-uri by fastify). Although I am not very happy about that, as I would usually prefer to use the standardized API (if it was actually usable ☹️).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, if we fail to use the new libraries, we should stick with what we have...

observe: false,
multicast: false,
confirmable: true,
Expand Down
Loading