Some checks failed
Test Custom Executables / test-custom-executables (push) Has been cancelled
CI / test (push) Has been cancelled
CI / prettier (push) Has been cancelled
CI / typecheck (push) Has been cancelled
Sync Base Action to claude-code-base-action / Sync base-action to claude-code-base-action repository (push) Has been cancelled
Test Claude Code Action / test-inline-prompt (push) Has been cancelled
Test Claude Code Action / test-prompt-file (push) Has been cancelled
Test Claude Env Feature / test-claude-env-with-comments (push) Has been cancelled
Test MCP Servers / test-mcp-integration (push) Has been cancelled
Test MCP Servers / test-mcp-config-flag (push) Has been cancelled
Test Settings Feature / test-settings-inline-allow (push) Has been cancelled
Test Settings Feature / test-settings-inline-deny (push) Has been cancelled
Test Settings Feature / test-settings-file-allow (push) Has been cancelled
Test Settings Feature / test-settings-file-deny (push) Has been cancelled
Fork of markwylde/claude-code-gitea-action@b744372 (v1.0.21) with the 'View job' link fixed to use GITHUB_RUN_NUMBER (per-repo index) instead of GITHUB_RUN_ID (global id), because Forgejo routes run pages by per-repo index. See VENDOR.txt.
76 lines
3.4 KiB
TypeScript
76 lines
3.4 KiB
TypeScript
import { expect, describe, it } from "bun:test";
|
|
import { ensureProperlyEncodedUrl } from "../src/github/operations/comment-logic";
|
|
|
|
describe("ensureProperlyEncodedUrl", () => {
|
|
it("should handle URLs with spaces", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix: update message&body=Description here";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A+update+message&body=Description+here";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should handle URLs with unencoded colons", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix: update message";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A+update+message";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should handle URLs that are already properly encoded", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A%20update%20message&body=Description%20here";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(url);
|
|
});
|
|
|
|
it("should handle URLs with partially encoded content", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A update message&body=Description here";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A+update+message&body=Description+here";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should handle URLs with special characters", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=feat(scope): add new feature!&body=This is a description with #123";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=feat%28scope%29%3A+add+new+feature%21&body=This+is+a+description+with+%23123";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should not encode the base URL", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...feature/new-branch?quick_pull=1&title=fix: test";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...feature/new-branch?quick_pull=1&title=fix%3A+test";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should handle malformed URLs gracefully", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix: test&body=";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A+test&body=";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should handle URLs with line breaks in parameters", () => {
|
|
const url =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix: test&body=Line 1\nLine 2";
|
|
const expected =
|
|
"https://github.com/owner/repo/compare/main...branch?quick_pull=1&title=fix%3A+test&body=Line+1%0ALine+2";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(expected);
|
|
});
|
|
|
|
it("should return null for completely invalid URLs", () => {
|
|
const url = "not-a-url-at-all";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(null);
|
|
});
|
|
|
|
it("should handle URLs with severe malformation", () => {
|
|
const url = "https://[invalid:url:format]/path";
|
|
expect(ensureProperlyEncodedUrl(url)).toBe(null);
|
|
});
|
|
});
|