Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Apparently, `RepoId::from_urn` also accepts strings without the `rad:` prefix.
did:key:z6MkgFq6...nBGz opened 7 months ago
pub fn from_urn(s: &str) -> Result<Self, IdError> {
    let s = s.strip_prefix(RAD_PREFIX).unwrap_or(s);
    let id = Self::from_canonical(s)?;

    Ok(id)
}

This is unexpected, since the constructor name mentions from_urn, which implies that it is in fact a URN, not just a bare string of characters.

This can be generally fine, since Self::from_canonical does the parsing of the multibase encoding, and the rad: prefix is not always needed. However, that string becomes ambiguous if something uses the same multibase encoding, whether in Radicle or from some other application.

It is hard to reverse this decision since this is used to parse RIDs, via FromStr, and we cannot know for sure how downstream crates are parsing, i.e. whether prefixed or not.

Changing this behaviour would be a non-backwards-compatible change. So, we should keep this in mind, and review at a later date.

z6MkgFq6...nBGz added crate=radicletype=refactor 7 months ago
levitte commented 7 months ago

I mostly think the function name is a bit weird... considering its input, I'd expect it to be called something like from_str