Download mods/diff/tests/git/probes/is-safe-ref-name.test.ts from SaylorTwift/claude-code: direct link, hf CLI and curl.
- Browser
- Download file 750 Bytes
-
https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/tests/git/probes/is-safe-ref-name.test.ts
- Command line
-
hf download hf://SaylorTwift/claude-code/mods/diff/tests/git/probes/is-safe-ref-name.test.ts
-
curl -L -o is-safe-ref-name.test.ts https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/tests/git/probes/is-safe-ref-name.test.ts
750 Bytes
| import { describe, expect, test, tier } from 'claude-code/testing' | |
| import Git from '../../../hooks/git' | |
| tier('builtin') | |
| describe('is-safe-ref-name', () => { | |
| test('branch refs under refs/ pass', () => { | |
| for (const ref of ['refs/heads/main', 'refs/heads/me/fh-diff_mod.2']) { | |
| expect(Git.isSafeRefName(ref), ref).toBe(true) | |
| } | |
| }) | |
| test('climbing, absolute, backslashed, control or lock names fail', () => { | |
| for (const ref of [ | |
| '', | |
| 'refs/../../etc/passwd', | |
| '/refs/heads/main', | |
| 'refs\\heads\\main', | |
| 'refs/heads/ma\u001bin', | |
| 'refs/heads/main.lock', | |
| 'refs/heads/.hidden', | |
| 'heads/main', | |
| 'refs//main', | |
| ]) { | |
| expect(Git.isSafeRefName(ref), ref).toBe(false) | |
| } | |
| }) | |
| }) | |