1 file changed, +19, -2
8e2bacdLink SSH submodule addresses as https
author
mogi <git@paramogi.world> on 29-11-2026 20:35 UTC
committer
mogi <git@paramogi.world> on 29-11-2026 20:35 UTC
parentdaea780
+19, -2
        @@ -1327,8 +1327,25 @@ pub fn path_href(git_ref: &RefInfo, repo_root: &str, path: &str) -> Option<Strin
13271327     git_ref
13281328         .submodules
13291329         .iter()
1330    -        .find(|(module, url)| *module == path && url.starts_with("https://"))
1331    -        .map(|(_, url)| url.clone())
    1330+        .filter(|(module, _)| *module == path)
    1331+        .find_map(|(_, url)| web_url(url))
    1332+}
    1333+
    1334+fn web_url(url: &str) -> Option<String> {
    1335+    if url.starts_with("https://") {
    1336+        return Some(url.to_string());
    1337+    }
    1338+    let (host, path) = match url.strip_prefix("ssh://git@") {
    1339+        Some(rest) => rest
    1340+            .split_once('/')
    1341+            .filter(|(host, _)| !host.contains(':'))?,
    1342+        None => url
    1343+            .strip_prefix("git@")?
    1344+            .split_once(':')
    1345+            .filter(|(host, _)| !host.contains('/'))?,
    1346+    };
    1347+    let path = path.trim_start_matches('/');
    1348+    (!host.is_empty() && !path.is_empty()).then(|| format!("https://{host}/{path}"))
13321349 }
13331350 
13341351 pub fn follow_links(git_ref: &RefInfo, path: &str) -> Option<String> {