aboutsummaryrefslogtreecommitdiff
path: root/common/misc.js
diff options
context:
space:
mode:
Diffstat (limited to 'common/misc.js')
-rw-r--r--common/misc.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/misc.js b/common/misc.js
index fac88bb..3c7dc46 100644
--- a/common/misc.js
+++ b/common/misc.js
@@ -12,6 +12,7 @@
* IMPORT browser
* IMPORT is_chrome
* IMPORT TYPE_NAME
+ * IMPORT TYPE_PREFIX
* IMPORTS_END
*/
@@ -207,6 +208,18 @@ function sanitize_csp_header(header, rule, block)
return {name: header.name, value: new_policy.join('')};
}
+/* Regexes and objest to use as/in schemas for parse_json_with_schema(). */
+const nonempty_string_matcher = /.+/;
+
+const matchers = {
+ sha256: /^[0-9a-f]{64}$/,
+ nonempty_string: nonempty_string_matcher,
+ component: [
+ new RegExp(`^[${TYPE_PREFIX.SCRIPT}${TYPE_PREFIX.BAG}]$`),
+ nonempty_string_matcher
+ ]
+};
+
/*
* EXPORTS_START
* EXPORT gen_nonce
@@ -219,5 +232,6 @@ function sanitize_csp_header(header, rule, block)
* EXPORT open_in_settings
* EXPORT is_privileged_url
* EXPORT sanitize_csp_header
+ * EXPORT matchers
* EXPORTS_END
*/