mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-26 18:35:05 +00:00
Merge reviewed contributor PR #3509 for incoming stewardship
This commit is contained in:
2 files changed
+18
-1
No files matched your search
@@ -525,7 +525,7 @@ def parse_instinct_file(content: str) -> list[dict]:
|
||||
in_frontmatter = False
|
||||
content_lines = []
|
||||
|
||||
for line in content.split('\n'):
|
||||
for line in content.removeprefix('\ufeff').split('\n'):
|
||||
if line.strip() == '---':
|
||||
if in_frontmatter:
|
||||
# End of frontmatter - content comes next
|
||||
|
||||
@@ -208,6 +208,23 @@ Prevents vulnerabilities.
|
||||
assert "Prevents vulnerabilities." in result[0]["content"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("newline", ["\n", "\r\n"])
|
||||
def test_parse_initial_utf8_bom(newline):
|
||||
content = SAMPLE_INSTINCT_YAML.replace("\n", newline)
|
||||
assert parse_instinct_file("\ufeff" + content) == parse_instinct_file(content)
|
||||
|
||||
|
||||
def test_parse_preserves_bom_inside_content():
|
||||
content = SAMPLE_INSTINCT_YAML.replace("Always write", "Always \ufeffwrite")
|
||||
assert "Always \ufeffwrite" in parse_instinct_file(content)[0]["content"]
|
||||
|
||||
|
||||
def test_load_instinct_file_with_utf8_bom(tmp_path):
|
||||
(tmp_path / "bom.yaml").write_text(SAMPLE_INSTINCT_YAML, encoding="utf-8-sig")
|
||||
instincts = _load_instincts_from_dir(tmp_path, "personal", "project")
|
||||
assert [instinct["id"] for instinct in instincts] == ["test-instinct"]
|
||||
|
||||
|
||||
def test_empty_content_no_error():
|
||||
content = """\
|
||||
---
|
||||
|
||||
Reference in new issue
Block a user