示例工程 32-deep-links-file-association
32-deep-links-file-association/app/.tsc/shared/work-file.js
export function validateWorkPath(filePath) {
return (filePath.length > 0 &&
filePath.length <= 260 &&
!filePath.includes("\0") &&
filePath.toLowerCase().endsWith(".xwrt"));
}
export function parseWorkFile(text) {
let raw;
try {
raw = JSON.parse(text);
}
catch {
return null;
}
if (typeof raw !== "object" || raw === null)
return null;
const { title, body } = raw;
if (typeof title !== "string" ||
title.length === 0 ||
title.length > 80 ||
typeof body !== "string" ||
body.length === 0 ||
body.length > 4000) {
return null;
}
return { title, body };
}
//# sourceMappingURL=work-file.js.map