MCPcopy Index your code
hub / github.com/parse-community/parse-server / validateFileUrlsInObject

Function validateFileUrlsInObject

src/FileUrlValidator.js:46–66  ·  view source on GitHub ↗

* Recursively scans an object for File type fields and validates their URLs. * @param {any} obj - The object to scan. * @param {Object} config - The Parse Server config object. * @throws {Parse.Error} If any File URL is not allowed.

(obj, config)

Source from the content-addressed store, hash-verified

44 * @throws {Parse.Error} If any File URL is not allowed.
45 */
46function validateFileUrlsInObject(obj, config) {
47 if (obj == null || typeof obj !== 'object') {
48 return;
49 }
50 if (Array.isArray(obj)) {
51 for (const item of obj) {
52 validateFileUrlsInObject(item, config);
53 }
54 return;
55 }
56 if (obj.__type === 'File' && obj.url) {
57 validateFileUrl(obj.url, config);
58 return;
59 }
60 for (const key of Object.keys(obj)) {
61 const value = obj[key];
62 if (value && typeof value === 'object') {
63 validateFileUrlsInObject(value, config);
64 }
65 }
66}
67
68module.exports = { validateFileUrl, validateFileUrlsInObject };

Callers 3

updateMethod · 0.85
createMethod · 0.85

Calls 1

validateFileUrlFunction · 0.85

Tested by

no test coverage detected