Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 8aee359

Browse files
committed
fix: enable domain names not starting with /ipns/ to be resolved with /dns
Signed-off-by: ljedrz <[email protected]>
1 parent 1c9ac1a commit 8aee359

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

http/src/v0/ipns.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct ResolveResponse {
4747
#[derive(Debug, Deserialize)]
4848
pub struct DnsQuery {
4949
// the name to resolve
50-
arg: StringSerialized<IpfsPath>,
50+
arg: String,
5151
}
5252

5353
pub fn dns<T: IpfsTypes>(
@@ -58,8 +58,20 @@ pub fn dns<T: IpfsTypes>(
5858

5959
async fn dns_query<T: IpfsTypes>(ipfs: Ipfs<T>, query: DnsQuery) -> Result<impl Reply, Rejection> {
6060
let DnsQuery { arg, .. } = query;
61+
// attempt to parse the argument prepended with "/ipns/" if it fails to parse like a compliant
62+
// IpfsPath and there is no leading slash
63+
let path = if !arg.starts_with('/') {
64+
if let Ok(parsed) = arg.parse() {
65+
Ok(parsed)
66+
} else {
67+
format!("/ipns/{}", arg).parse()
68+
}
69+
} else {
70+
arg.parse()
71+
}
72+
.map_err(StringError::from)?;
6173
let path = ipfs
62-
.resolve(&arg.into_inner())
74+
.resolve(&path)
6375
.await
6476
.map_err(StringError::from)?
6577
.to_string();

0 commit comments

Comments
 (0)