rust-multiaddr icon indicating copy to clipboard operation
rust-multiaddr copied to clipboard

Should we add an empty MA to the failure test?

Open diegomrsantos opened this issue 2 years ago • 5 comments

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

diegomrsantos avatar Mar 22 '23 13:03 diegomrsantos

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

thomaseizinger avatar Mar 22 '23 14:03 thomaseizinger

Doesn't "+" mean 1 or more?

diegomrsantos avatar Mar 22 '23 15:03 diegomrsantos

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

Menduist avatar Mar 22 '23 16:03 Menduist

Doesn't "+" mean 1 or more?

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

thomaseizinger avatar Mar 22 '23 21:03 thomaseizinger

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

thomaseizinger avatar Mar 22 '23 21:03 thomaseizinger