2014-07-25 14:42:42 +04:00
|
|
|
/**
|
|
|
|
* google-caja uses url() and id() to verify if the values are allowed.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Check if URL is allowed
|
|
|
|
* URLs are allowed if they start with http://, https://, or /.
|
|
|
|
*/
|
2015-10-28 14:36:45 +03:00
|
|
|
let url = 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.
|
|
|
|
*/
|
2015-10-28 14:36:45 +03:00
|
|
|
let id = function (id) {
|
2014-07-25 14:42:42 +04:00
|
|
|
return id;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
2015-10-28 14:36:45 +03:00
|
|
|
url,
|
|
|
|
id
|
2014-10-25 01:09:50 +04:00
|
|
|
};
|