mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-14 00:07:00 +01:00
* feat: let owners leave chosen files unredacted (#941) Redacting self-citations in a bibliography reveals which papers are the authors' own. Owners can now pick files whose content is served as written; file names are still redacted. Patterns follow .gitignore rules. The form gets a file picker fed by GitHub's tree API, and the terms box grows with its content and only warns about regex symbols that can stop a term from matching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: honour !patterns, keep picked braces literal, preview unredacted README - Patterns now apply in order and the last match wins, as in .gitignore, so "*.bib" then "!private.bib" excludes private.bib instead of preserving every other file. - Picked paths escape glob characters, braces included, with a backslash; "[{]" did not survive brace expansion. - The README preview drops terms when the README is an unredacted file, and refreshes when the list changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep rule order when deduplicating unredacted-file patterns Rules apply in order and the last match wins, so dedupe keeps the last copy of a repeated pattern instead of the first. The picker also keeps a plain path in its place when it follows another rule, rather than moving it to the front as a pick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: apply unredacted-file rules to folders, as in .gitignore A rule that matches a folder now covers every file inside it, so "*.bib" then "!private" keeps private/refs.bib redacted. A trailing "/" limits a rule to folders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: folder unchecks win over broad rules; accept short commit hashes - Unchecking a folder that a broader rule such as "*.bib" still covers appends a "!/folder/" exclusion, so its files really go back to being redacted. - The tree endpoint accepts the 6+ character hashes the commit field allows and resolves them to a full SHA before reading the tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: picker counts folder rules exactly as the server does Rules ending in "/" stay patterns instead of being read as picked files, and the checkboxes now run the saved rule list (picks, then patterns) through the server's matcher, so the dialog cannot show files as redacted that the server leaves unredacted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: insert escaped terms literally in "Match as written" String.replace expanded "$&", "$'" and "$1" in the term, so the fix could corrupt the line. Splice by index instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
const { expect } = require("chai");
|
|
require("ts-node/register/transpile-only");
|
|
const { termHints, escapeTermLine } = require("../src/core/term-hints");
|
|
|
|
describe("term hints", function () {
|
|
it("ignores dots, hyphens and emails", function () {
|
|
expect(termHints("mchen-research\nhartwell.edu\nmaya.chen@cs.example.edu\nA, B #1")).to.deep.equal([]);
|
|
});
|
|
|
|
it("flags symbols that change what a term matches", function () {
|
|
expect(termHints("Maya Chen\nSmith (MIT)\nC++")).to.deep.equal([
|
|
{ line: 1, term: "Smith (MIT)", symbols: ["(", ")"] },
|
|
{ line: 2, term: "C++", symbols: ["+"] },
|
|
]);
|
|
});
|
|
|
|
it("skips escaped symbols and the replacement side", function () {
|
|
expect(termHints("Smith \\(MIT\\)\nAnon=>A (B)")).to.deep.equal([]);
|
|
});
|
|
|
|
it("escapes one line and keeps its replacement", function () {
|
|
expect(escapeTermLine("a\nSmith (MIT).x=>Anon (1)\nb", 1)).to.equal("a\nSmith \\(MIT\\)\\.x=>Anon (1)\nb");
|
|
expect(escapeTermLine("C\\+\\+ +", 0)).to.equal("C\\+\\+ \\+");
|
|
});
|
|
|
|
it("inserts terms containing $ sequences literally", function () {
|
|
expect(escapeTermLine("a$&b (x)", 0)).to.equal("a\\$&b \\(x\\)");
|
|
expect(escapeTermLine(" $'(y)=>z", 0)).to.equal(" \\$'\\(y\\)=>z");
|
|
expect(escapeTermLine("$1+", 0)).to.equal("\\$1\\+");
|
|
});
|
|
});
|