multiformats / rust-multiaddr

multiaddr implementation in rust
https://crates.io/crates/multiaddr
Other
88 stars 47 forks source link

Should we add an empty MA to the failure test? #85

Open diegomrsantos opened 1 year ago

diegomrsantos commented 1 year ago

Seems that the spec doesn't allow an empty MA.

Human-readable multiaddr: (/<protoName string>/<value string>)+
Example: /ip4/127.0.0.1/udp/1234
Machine-readable multiaddr: (<protoCode uvarint><value []byte>)+
Same example: 0x4 0x7f 0x0 0x0 0x1 0x91 0x2 0x4 0xd2
Values are usually length-prefixed with a uvarint
thomaseizinger commented 1 year ago

Where in the provided snippet do you read that an empty address is not allowed?

diegomrsantos commented 1 year ago

Doesn't "+" mean 1 or more?

Menduist commented 1 year ago

Also see https://github.com/multiformats/go-multiaddr/issues/104

thomaseizinger commented 1 year ago

Doesn't "+" mean 1 or more?

Ah yes, I didn't realize that was actually a regular expression.

thomaseizinger commented 1 year ago

We could deprecate the Multiaddr::empty function and replace it with a Multiaddr::new(Protocol) one.