Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Allow URLs to be used for git/api records
Alexis Sellier committed 4 years ago
commit 8ca59d11a8e38c8e412f183fb8a2d702c46d4262
parent 73f2a988c9f509d737bb5b9a51da48e39c69db74
1 file changed +24 -4
modified src/base/seeds/Seed.ts
@@ -35,13 +35,33 @@ export class Seed {
    assert(isDomain(seed.host), `invalid seed host: ${seed.host}`);
    assert(/^[a-z0-9]+$/.test(seed.id), `invalid seed id ${seed.id}`);

-
    seed.api && assert(isDomain(seed.api), `invalid seed api host ${seed.api}`);
-
    seed.git && assert(isDomain(seed.git), `invalid seed git host ${seed.git}`);
+
    let api = null;
+
    let git = null;
+

+
    if (seed.api) {
+
      try {
+
        const url = new URL(seed.api);
+
        api = url.hostname;
+
      } catch {
+
        api = seed.api;
+
      }
+
      assert(isDomain(api), `invalid seed api host ${api}`);
+
    }
+

+
    if (seed.git) {
+
      try {
+
        const url = new URL(seed.git);
+
        git = url.hostname;
+
      } catch {
+
        git = seed.git;
+
      }
+
      assert(isDomain(git), `invalid seed git host ${git}`);
+
    }

    // The `git` and `api` keys being more specific take
    // precedence over the `host`, if available.
-
    const api = seed.api ?? seed.host;
-
    const git = seed.git ?? seed.host;
+
    api = api ?? seed.host;
+
    git = git ?? seed.host;

    this.api = { host: api, port: cfg.seed.api.port };
    this.git = { host: git, port: cfg.seed.git.port };