GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(client-runtime): local repository clone folders keep # and ? in t… · patroza/t3code@4732927

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/client-runtime/src/operations
    • projects.test.ts
    • projects.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/client-runtime/src/operations/projects.test.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/operations/projects.test.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ describe("add project shared logic", () => {
143143
expect(getCloneDirectoryName("C:\\src\\repo.git")).toBe("repo");
144144
expect(getCloneDirectoryName("[email protected]:repo.git")).toBe("repo");
145145
expect(getCloneDirectoryName(" https://github.com/owner/repo.git ")).toBe("repo");
146+
expect(getCloneDirectoryName("/srv/git/firmware#2.git")).toBe("firmware#2");
147+
expect(getCloneDirectoryName("~/git/what?.git")).toBe("what?");
148+
expect(getCloneDirectoryName("../firmware#2.git")).toBe("firmware#2");
149+
expect(getCloneDirectoryName("C:\\src\\firmware#2.git")).toBe("firmware#2");
150+
expect(getCloneDirectoryName("github.com:owner/repo.git?ref=main")).toBe("repo");
146151
});
147152

148153
it("lays clone folders out like ghq only when asked, and only when the URL is safe", () => {
Collapse file

‎packages/client-runtime/src/operations/projects.ts‎

Copy file name to clipboardExpand all lines: packages/client-runtime/src/operations/projects.ts
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import type {
1212
} from "@t3tools/contracts";
1313
import { SourceControlProviderKind } from "@t3tools/contracts";
1414
import { cloneUrlRepositoryPath } from "@t3tools/shared/cloneUrl";
15-
import { isAbsolutePath, isExplicitRelativePath, newProjectFolderName } from "@t3tools/shared/path";
15+
import {
16+
isAbsolutePath,
17+
isExplicitRelativePath,
18+
isHostPath,
19+
newProjectFolderName,
20+
} from "@t3tools/shared/path";
1621
import * as Arr from "effect/Array";
1722
import * as Option from "effect/Option";
1823
import * as Order from "effect/Order";
@@ -234,7 +239,11 @@ export function getAddProjectInitialQuery(baseDirectory: string | null | undefin
234239
}
235240

236241
export function getCloneDirectoryName(repositoryOrRemoteUrl: string | null | undefined): string {
237-
const withoutQuery = (repositoryOrRemoteUrl ?? "").split(/[?#]/)[0]?.trim() ?? "";
242+
const trimmed = (repositoryOrRemoteUrl ?? "").trim();
243+
// A local path keeps `#` and `?` in its name; in a URL they start a query or fragment.
244+
const isLocalPath =
245+
!trimmed.includes("://") && (isHostPath(trimmed) || isExplicitRelativePath(trimmed));
246+
const withoutQuery = isLocalPath ? trimmed : (trimmed.split(/[?#]/)[0] ?? "");
238247
const schemeIndex = withoutQuery.indexOf("://");
239248
const hasHost = schemeIndex >= 0 || /^[^/\\:]+@[^/\\:]+:/.test(withoutQuery);
240249
const pathPart = schemeIndex >= 0 ? withoutQuery.slice(schemeIndex + "://".length) : withoutQuery;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.