Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Make `parseEnsLabel` stricter
Alexis Sellier committed 4 years ago
commit b585a5916357cdb7efa062aa395229107f0944c9
parent 3bfb79dd4760be07c9cb260a62238059b768a498
2 files changed +6 -9
modified src/base/resolver/Query.svelte
@@ -26,7 +26,7 @@
        alert("Radicle IDs are not yet supported");
      } else {
        let label = utils.parseEnsLabel(query, config);
-
        if (label?.includes(".")) {
+
        if (label.includes(".")) {
          error = true;
        } else {
          // Jump straight to org, if the ENS entry points to an org. Otherwise it checks if the
modified src/utils.ts
@@ -73,13 +73,11 @@ export function capitalize(s: string): string {

// Takes a domain name, eg. 'cloudhead.radicle.eth' and
// returns the label, eg. 'cloudhead', otherwise `undefined`.
-
export function parseEnsLabel(name: string | undefined, config: Config): string | undefined {
-
  if (name) {
-
    const domain = config.registrar.domain.replace(".", "\\.");
-
    const label = name.replace(new RegExp(`\\.${domain}$`), "");
+
export function parseEnsLabel(name: string, config: Config): string {
+
  const domain = config.registrar.domain.replace(".", "\\.");
+
  const label = name.replace(new RegExp(`\\.${domain}$`), "");

-
    return label;
-
  }
+
  return label;
}

// Takes a URL, eg. "https://twitter.com/cloudhead", and return "cloudhead".
@@ -172,8 +170,7 @@ export async function querySubgraph(

// Format a name.
export function formatName(input: string, config: Config): string {
-
  const name = parseEnsLabel(input, config);
-
  return name || input;
+
  return parseEnsLabel(input, config);
}

// Create a Radicle ID from a root hash.