Spaces:
Sleeping
Sleeping
Download src/redact.js from AustinWealth/cc-space: direct link, hf CLI and curl.
- Browser
- Download file 498 Bytes
-
https://huggingface.co/spaces/AustinWealth/cc-space/resolve/main/src/redact.js
- Command line
-
hf download hf://spaces/AustinWealth/cc-space/src/redact.js
-
curl -L -o redact.js https://huggingface.co/spaces/AustinWealth/cc-space/resolve/main/src/redact.js
498 Bytes
| // Remove obvious personal identifiers before text leaves the server. | |
| // Best effort only: the UI also tells students not to type personal details. | |
| const EMAIL = /[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g; | |
| const PHONEISH = /\+?\d[\d\s().-]{5,}\d/g; | |
| const MATRIC = /\b[A-Za-z]{2,6}[/-]\d{2,}(?:[/-]\d+)+\b/g; | |
| export function redact(text) { | |
| return String(text) | |
| .replace(EMAIL, "[email]") | |
| .replace(MATRIC, "[id]") | |
| .replace(PHONEISH, (m) => (m.replace(/\D/g, "").length >= 7 ? "[number]" : m)); | |
| } | |