diff options
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/utils.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js index 44e17324b85..e3911752aaa 100644 --- a/addons/web/static/src/js/core/utils.js +++ b/addons/web/static/src/js/core/utils.js @@ -440,6 +440,18 @@ var utils = { return (/^\d+(\.\d*)? [^0-9]+$/).test(v); }, /** + * Returns whether the given anchor is valid. + * + * This test is useful to prevent a crash that would happen if using an invalid + * anchor as a selector. + * + * @param {string} anchor + * @returns {boolean} + */ + isValidAnchor: function (anchor) { + return /^#[\w-]+$/.test(anchor); + }, + /** * @param {any} node * @param {any} human_readable * @param {any} indent |
