2014-07-25 14:42:42 +04:00
|
|
|
/**
|
|
|
|
* google-caja uses url() and id() to verify if the values are allowed.
|
|
|
|
*/
|
2020-06-17 11:35:46 +03:00
|
|
|
|
2014-07-25 14:42:42 +04:00
|
|
|
/**
|
|
|
|
* Check if URL is allowed
|
|
|
|
* URLs are allowed if they start with http://, https://, or /.
|
2017-05-15 19:51:19 +03:00
|
|
|
* NOTE: # urls are not allowed as clicking them will break the editor when clicked
|
2014-07-25 14:42:42 +04:00
|
|
|
*/
|
2020-06-17 11:35:46 +03:00
|
|
|
let allowedUrl = function (url) {
|
2014-10-25 01:09:50 +04:00
|
|
|
url = url.toString().replace(/['"]+/g, '');
|
2014-07-25 14:42:42 +04:00
|
|
|
if (/^https?:\/\//.test(url) || /^\//.test(url)) {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if ID is allowed
|
|
|
|
* All ids are allowed at the moment.
|
|
|
|
*/
|
2020-06-17 11:35:46 +03:00
|
|
|
let allowedId = function (id) {
|
2014-07-25 14:42:42 +04:00
|
|
|
return id;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
2020-06-17 11:35:46 +03:00
|
|
|
url: allowedUrl,
|
|
|
|
id: allowedId
|
2014-10-25 01:09:50 +04:00
|
|
|
};
|