Files
anonymous_github/test/github-stream-url.test.js
T
2026-05-06 20:00:59 +03:00

32 lines
946 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { expect } = require("chai");
require("ts-node/register/transpile-only");
const { githubRawFileUrl } = require("../src/core/source/GitHubStream");
describe("githubRawFileUrl", function () {
it("encodes Chinese file names for GitHub raw URLs", function () {
const url = githubRawFileUrl(
"owner",
"repo",
"abc123",
"V 站怎么有这么多人以 PC 为荣? - V2EX.md"
);
expect(url).to.equal(
"https://github.com/owner/repo/raw/abc123/V%20%E7%AB%99%E6%80%8E%E4%B9%88%E6%9C%89%E8%BF%99%E4%B9%88%E5%A4%9A%E4%BA%BA%E4%BB%A5%20PC%20%E4%B8%BA%E8%8D%A3%EF%BC%9F%20-%20V2EX.md"
);
});
it("encodes reserved characters without escaping path separators", function () {
const url = githubRawFileUrl(
"owner",
"repo",
"abc123",
"docs/a?b#c%d.md"
);
expect(url).to.equal(
"https://github.com/owner/repo/raw/abc123/docs/a%3Fb%23c%25d.md"
);
});
});