Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,23 @@
|
||||
const FORMULA_NEUTRALIZER = "'";
|
||||
const FORMULA_PREFIXES = new Set(["=", "+", "-", "@"]);
|
||||
const CONTROL_PREFIXES = new Set(["\t", "\r", "\n"]);
|
||||
|
||||
export function neutralizeSpreadsheetFormula(value: string): string {
|
||||
return hasUnsafeSpreadsheetPrefix(value) ? `${FORMULA_NEUTRALIZER}${value}` : value;
|
||||
}
|
||||
|
||||
function hasUnsafeSpreadsheetPrefix(value: string): boolean {
|
||||
for (const char of value) {
|
||||
if (FORMULA_PREFIXES.has(char) || CONTROL_PREFIXES.has(char)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (char.trim() === "") {
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in new issue
Block a user