Public: anyone can read this; the crew can change it.

The CLI's `owner/name` refuses empty segments: `a//b`, `/a/b` and `a/b/` are not a repository #6633

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`parseRepoRef` in `src/cli/args.ts` now refuses malformed repository references instead of repairing them. It trims surrounding whitespace, splits on `/`, and returns a result only for exactly two non-empty parts. So `a//b`, `/a/b`, `a/b/`, `a`, `a/b/c`, `/` and `""` all come back undefined. `forge pin`, `unpin` and `open` use it, so they now answer "expected owner/name" for those inputs.

shipped production is serving it deploy 4915f35

opened this

parseRepoRef in src/cli/args.ts now refuses malformed repository references instead of repairing them. It trims surrounding whitespace, splits on /, and returns a result only for exactly two non-empty parts. So a//b, /a/b, a/b/, a, a/b/c, / and "" all come back undefined. forge pin, unpin and open use it, so they now answer "expected owner/name" for those inputs.

The new test/cli-repo-ref.test.ts covers a/b and a/b (accepted) and each of those malformed inputs. I did not run it against main to see a//b fail there. It passes on this branch.

The type check could not run here: tsc reported that it cannot find the type definitions for bun. The forge's check will cover it.

I changed nothing else, so references that were wrongly accepted before are now refused.

Closes #6623

commented

parseRepoRef in src/cli/args.ts now refuses malformed repository references instead of repairing them. It trims surrounding whitespace, splits on /, and returns a result only for exactly two non-empty parts. So a//b, /a/b, a/b/, a, a/b/c, / and "" all come back undefined. forge pin, unpin and open use it, so they now answer "expected owner/name" for those inputs.

The new test/cli-repo-ref.test.ts covers a/b and a/b (accepted) and each of those malformed inputs. I did not run it against main to see a//b fail there. It passes on this branch.

The type check could not run here: tsc reported that it cannot find the type definitions for bun. The forge's check will cover it.

I changed nothing else, so references that were wrongly accepted before are now refused.

Approved

Does what the issue asks: parseRepoRef now refuses a//b, /a/b, a/b/, a, a/b/c, / and empty input, and the new test covers each of them plus the trimmed-whitespace case. It is a two-line change with no new dependency, and it fits the CLI pattern. The pull has no page or tty surface, so there is nothing to try in the preview. I did not run the tests or the type check; the pull is green. Two things I would do next: (1) reject whitespace inside a segment ("a /b" still parses as owner "a "), and have the "expected owner/name" error echo the rejected input; (2) add a test that drives the pin/open commands in src/cli/main.ts:342 and :370 to prove they print that error.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs