Don't show port in clone URL if it is the default port

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2023-04-12 10:02:04 +02:00
parent 6efe60984b
commit 2d58c600ad
3 changed files with 15 additions and 8 deletions
+12 -5
View File
@@ -1,19 +1,26 @@
<script lang="ts">
import type { BaseUrl } from "@httpd-client";
import Clipboard from "@app/components/Clipboard.svelte";
import Floating from "@app/components/Floating.svelte";
import { closeFocused } from "@app/components/Floating.svelte";
import { parseRepositoryId } from "@app/lib/utils";
import { config } from "@app/lib/config";
import Clipboard from "@app/components/Clipboard.svelte";
import Floating from "@app/components/Floating.svelte";
export let baseUrl: BaseUrl;
export let id: string;
export let name: string;
$: radCloneUrl = `rad clone ${id}`;
$: gitCloneUrl = `git clone ${baseUrl.scheme}://${baseUrl.hostname}:${
baseUrl.port
}/${parseRepositoryId(id)?.pubkey ?? id}.git ${name}`;
$: portFragment =
baseUrl.scheme === config.seeds.defaultHttpdScheme &&
baseUrl.port === config.seeds.defaultHttpdPort
? ""
: `:${baseUrl.port}`;
$: gitCloneUrl = `git clone ${baseUrl.scheme}://${
baseUrl.hostname
}${portFragment}/${parseRepositoryId(id)?.pubkey ?? id}.git ${name}`;
</script>
<style>
+2 -2
View File
@@ -55,7 +55,7 @@ test("copy to clipboard", async ({ page, browserName, context }) => {
await page.getByText("Clone").click();
await page
.locator(
`text=git clone http://127.0.0.1:8080/${rid
`text=git clone http://127.0.0.1/${rid
.replace("rad:", "")
.substring(0, 10)}`,
)
@@ -66,7 +66,7 @@ test("copy to clipboard", async ({ page, browserName, context }) => {
.locator(".clipboard")
.click();
await expectClipboard(
`git clone http://127.0.0.1:8080/${rid.replace(
`git clone http://127.0.0.1/${rid.replace(
"rad:",
"",
)}.git source-browsing`,
+1 -1
View File
@@ -250,7 +250,7 @@ test("clone modal", async ({ page }) => {
await page.getByText("Clone").click();
await expect(page.locator(`text=rad clone ${rid}`)).toBeVisible();
await expect(
page.locator(`text=http://127.0.0.1:8080/${rid.replace("rad:", "")}.git`),
page.locator(`text=http://127.0.0.1/${rid.replace("rad:", "")}.git`),
).toBeVisible();
});