Skip to content

Commit 8c01896

Browse files
committed
fix: handle option-like attachment filenames
1 parent 0b09479 commit 8c01896

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

skills/attach-github-pr-files/scripts/upload.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ fi
5757

5858
output=$(mktemp)
5959
trap 'rm -f "$output"' EXIT HUP INT TERM
60-
filename=$(basename "$file")
61-
encoded_filename=$(node -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$filename")
60+
filename=$(basename -- "$file")
61+
encoded_filename=$(node -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' -- "$filename")
6262

6363
set -- \
6464
--fail-with-body --silent --show-error \

test-node/cli.test.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,15 @@ test("skill uploader uses the repository override", async (context) => {
121121

122122
test("skill uploader percent-encodes UTF-8 filenames", async (context) => {
123123
const repository = await temporaryRepository(context);
124-
const file = join(repository, UNICODE_FILENAME);
124+
const filename = `--${UNICODE_FILENAME}`;
125+
const file = join(repository, filename);
126+
const markdown = `[${filename}](https://example.test/a/id/${encodeURIComponent(filename)})`;
125127
await writeFile(file, "unicode attachment\n");
126128
const serviceUrl = await startServer(context, {
127129
alt: "Unicode skill",
128130
body: "unicode attachment\n",
129-
filename: UNICODE_FILENAME,
130-
markdown: UNICODE_MARKDOWN.trim(),
131+
filename,
132+
markdown,
131133
token: "unicode-skill-token",
132134
});
133135

@@ -144,7 +146,7 @@ test("skill uploader percent-encodes UTF-8 filenames", async (context) => {
144146

145147
assert.equal(result.stderr, "");
146148
assert.equal(result.exitCode, 0);
147-
assert.equal(result.stdout, UNICODE_MARKDOWN);
149+
assert.equal(result.stdout, `${markdown}\n`);
148150
});
149151

150152
test("skill uploader reads the user-level service profile", async (context) => {

0 commit comments

Comments
 (0)