Skip to content

Commit 757d63c

Browse files
committed
v0.1.1: URL-context rule keeps wraps inside a URL tight
If the prev line contains '://', the wrap almost certainly broke somewhere inside a URL (mid-domain, mid-path). Join with no space instead of inserting one. Fixes 'downloa d/v0.1.0' output seen in real-world testing.
1 parent 56463ad commit 757d63c

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "tidy-paste",
33
"displayName": "Tidy Paste",
44
"description": "Cleans terminal-wrapped text on copy from VS Code's integrated terminal so pasted content arrives without stray line breaks or trailing whitespace.",
5-
"version": "0.1.0",
5+
"version": "0.1.1",
66
"publisher": "miller-joe",
77
"license": "MIT",
88
"repository": {

src/cleaner.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ function joinSeparator(prev: string, next: string): string {
409409
const firstChar = next[0]!;
410410
if (/\s/.test(lastChar) || /\s/.test(firstChar)) return "";
411411
if (CONTINUATION_STARTERS.has(firstChar)) return "";
412+
// URL context: if the prev line contains a URL scheme, the wrap almost
413+
// certainly broke inside the URL (mid-domain, mid-path). No space.
414+
if (/:\/\//.test(prev) && /^[A-Za-z0-9]/.test(firstChar)) return "";
412415
return " ";
413416
}
414417

test/cleaner.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ describe("separate shell commands don't merge", () => {
107107
});
108108
});
109109

110+
describe("URL mid-domain wraps", () => {
111+
it("joins a URL wrapped mid-domain without inserting a space", () => {
112+
const input =
113+
"● v0.1.0 shipped. Download: https://github.com/miller-joe/tidy-paste/releases/downloa\n" +
114+
"d/v0.1.0/tidy-paste-0.1.0.vsix";
115+
const r = cleanCopiedText(input, { terminalColumns: 0, appWrapColumn: 0 });
116+
expect(r.text).toContain("/releases/download/v0.1.0/");
117+
expect(r.text).not.toContain("downloa d");
118+
});
119+
});
120+
110121
describe("smart join separator", () => {
111122
it("no space when next line starts with '.' (URL continuation)", () => {
112123
const input =

0 commit comments

Comments
 (0)