mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-28 17:50:28 +08:00
Make route organization RESTful
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<script lang="typescript">
|
||||
import { onMount } from 'svelte';
|
||||
import { ethers } from 'ethers';
|
||||
import { navigate } from 'svelte-routing';
|
||||
import type { Config } from '@app/config';
|
||||
import * as utils from '@app/utils';
|
||||
import Error from '@app/Error.svelte';
|
||||
|
||||
export let config: Config;
|
||||
export let query: string | null;
|
||||
|
||||
let error = false;
|
||||
|
||||
onMount(() => {
|
||||
if (query) {
|
||||
if (ethers.utils.isAddress(query)) {
|
||||
// Go to org.
|
||||
navigate(`/orgs/${query}`, { replace: true });
|
||||
} else if (utils.isRadicleId(query)) {
|
||||
// Go to Radicle entity.
|
||||
alert("Radicle IDs are not yet supported");
|
||||
} else {
|
||||
let label = utils.parseEnsLabel(query, config);
|
||||
if (label.includes(".")) {
|
||||
error = true;
|
||||
} else {
|
||||
navigate(`/registrations/${label}`, { replace: true });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
navigate('/');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<main>
|
||||
{#if error}
|
||||
<Error on:close={() => navigate('/')}>
|
||||
Invalid query string “{query}”
|
||||
</Error>
|
||||
{/if}
|
||||
</main>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script lang="typescript">
|
||||
import { Route } from "svelte-routing";
|
||||
import Resolve from '@app/base/resolver/Query.svelte';
|
||||
import type { Config } from '@app/config';
|
||||
import * as utils from '@app/utils';
|
||||
|
||||
export let config: Config;
|
||||
</script>
|
||||
|
||||
<Route path="/resolver/query" let:location>
|
||||
<Resolve {config} query={utils.getSearchParam("q", location)} />
|
||||
</Route>
|
||||
Reference in New Issue
Block a user