Covertness/coap-rs

Empty path components dropped

chrysn opened this issue · 1 comments

CoAP URIs distinguish between coap://foo/path/parts and coap://foo/path/parts/ (as does any other type of URI). While the former is encoded in two CoAP Uri-Path options ("path", "parts"), the latter is encoded in three ("path", "parts", "") with the third having zero length.

The .set_path() / .get_path() method pair appears to drop the distinction (set_path("/path/parts/") followed by get_path() returns "/path/parts"), indicating that the distinction is not made in the coap-rs library.

Looking at the code, it appears that it is sufficient to drop the if-is-empty check for components, though things might still need special treatment then to avoid inserting an empty component at the beginning when a path is passed in with a leading slash.

Fixed. Help review it if you want. Thanks. #38