mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-30 16:50:47 +08:00
Refactor BaseUrl string conversion
We're only using this as a string, so no need to convert it to an URL.
This commit is contained in:
+2
-2
@@ -94,8 +94,8 @@ export function formatEditedCaption(
|
||||
} edited ${absoluteTimestamp(timestamp)}`;
|
||||
}
|
||||
|
||||
export function baseUrlToUrl(baseUrl: BaseUrl): URL {
|
||||
return new URL(`${baseUrl.scheme}://${baseUrl.hostname}:${baseUrl.port}`);
|
||||
export function baseUrlToString(baseUrl: BaseUrl): string {
|
||||
return `${baseUrl.scheme}://${baseUrl.hostname}:${baseUrl.port}`;
|
||||
}
|
||||
|
||||
// Generates a publicly shareable link.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import { api, httpdStore } from "@app/lib/httpd";
|
||||
import { deduplicateStore } from "@app/lib/deduplicateStore";
|
||||
import { baseUrlToUrl } from "@app/lib/utils";
|
||||
import { baseUrlToString } from "@app/lib/utils";
|
||||
import { getProjectsListingData } from "@app/lib/projects";
|
||||
import { handleError } from "@app/views/home/error";
|
||||
import { isDelegate } from "@app/lib/roles";
|
||||
@@ -160,10 +160,7 @@
|
||||
</div>
|
||||
{:else if localProjects instanceof Error}
|
||||
<ErrorMessage
|
||||
{...handleError(
|
||||
localProjects,
|
||||
baseUrlToUrl(api.baseUrl).toString(),
|
||||
)} />
|
||||
{...handleError(localProjects, baseUrlToString(api.baseUrl))} />
|
||||
{:else if !localProjects?.length}
|
||||
<div class="heading">No local projects</div>
|
||||
<div class="label">
|
||||
@@ -219,7 +216,7 @@
|
||||
<ErrorMessage
|
||||
{...handleError(
|
||||
preferredSeedProjects,
|
||||
baseUrlToUrl(api.baseUrl).toString(),
|
||||
baseUrlToString(api.baseUrl),
|
||||
)} />
|
||||
{:else}
|
||||
<div class="heading">Nothing to see here</div>
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { ProjectWithListingData } from "@app/lib/projects";
|
||||
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { config } from "@app/lib/config";
|
||||
import { baseUrlToUrl, isLocal } from "@app/lib/utils";
|
||||
import { baseUrlToString, isLocal } from "@app/lib/utils";
|
||||
import { getProjectsListingData } from "@app/lib/projects";
|
||||
import { handleError } from "@app/views/nodes/error";
|
||||
|
||||
@@ -77,6 +77,6 @@ export async function loadNodeRoute(
|
||||
},
|
||||
};
|
||||
} catch (error: any) {
|
||||
return handleError(error, baseUrlToUrl(api.baseUrl).toString());
|
||||
return handleError(error, baseUrlToString(api.baseUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,9 +509,9 @@
|
||||
style:border-radius="var(--border-radius-small">
|
||||
<ErrorMessage
|
||||
title="Failed to load diff for this revision"
|
||||
description="Make sure you are able to connect to the seed <code>${utils
|
||||
.baseUrlToUrl(api.baseUrl)
|
||||
.toString()}</code>"
|
||||
description="Make sure you are able to connect to the seed <code>${utils.baseUrlToString(
|
||||
api.baseUrl,
|
||||
)}</code>"
|
||||
{error} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import { COMMITS_PER_PAGE } from "./router";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { baseUrlToUrl } from "@app/lib/utils";
|
||||
import { baseUrlToString } from "@app/lib/utils";
|
||||
import { groupCommits } from "@app/lib/commit";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
@@ -160,9 +160,9 @@
|
||||
<div class="message">
|
||||
<ErrorMessage
|
||||
title="Couldn't load commits"
|
||||
description="Make sure you are able to connect to the seed <code>${baseUrlToUrl(
|
||||
description="Make sure you are able to connect to the seed <code>${baseUrlToString(
|
||||
api.baseUrl,
|
||||
).toString()}</code>"
|
||||
)}</code>"
|
||||
{error} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { ISSUES_PER_PAGE } from "./router";
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { baseUrlToUrl, isLocal } from "@app/lib/utils";
|
||||
import { baseUrlToString, isLocal } from "@app/lib/utils";
|
||||
import capitalize from "lodash/capitalize";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
@@ -176,9 +176,9 @@
|
||||
{#if error}
|
||||
<ErrorMessage
|
||||
title="Couldn't load issues"
|
||||
description="Please make sure you are able to connect to the seed <code>${baseUrlToUrl(
|
||||
description="Please make sure you are able to connect to the seed <code>${baseUrlToString(
|
||||
api.baseUrl,
|
||||
).toString()}</code>"
|
||||
)}</code>"
|
||||
{error} />
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import { PATCHES_PER_PAGE } from "./router";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { baseUrlToUrl, isLocal } from "@app/lib/utils";
|
||||
import { baseUrlToString, isLocal } from "@app/lib/utils";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
@@ -195,9 +195,9 @@
|
||||
{#if error}
|
||||
<ErrorMessage
|
||||
title="Couldn't load patches"
|
||||
description="Please make sure you are able to connect to the seed <code>${baseUrlToUrl(
|
||||
description="Please make sure you are able to connect to the seed <code>${baseUrlToString(
|
||||
api.baseUrl,
|
||||
).toString()}</code>"
|
||||
)}</code>"
|
||||
{error} />
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ErrorRoute, NotFoundRoute } from "@app/lib/router/definitions";
|
||||
import type { ProjectRoute } from "@app/views/projects/router";
|
||||
|
||||
import { baseUrlToUrl, isLocal } from "@app/lib/utils";
|
||||
import { baseUrlToString, isLocal } from "@app/lib/utils";
|
||||
import { ResponseParseError, ResponseError } from "@httpd-client/lib/fetcher";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { get } from "svelte/store";
|
||||
@@ -10,7 +10,7 @@ export function handleError(
|
||||
error: Error | ResponseParseError | ResponseError,
|
||||
route: ProjectRoute,
|
||||
): NotFoundRoute | ErrorRoute {
|
||||
const url = baseUrlToUrl(route.node);
|
||||
const url = baseUrlToString(route.node);
|
||||
if (error instanceof ResponseError && error.status === 404) {
|
||||
let subject;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user