2014-07-25 14:42:42 +04:00
|
|
|
/**
|
|
|
|
* google-caja uses url() and id() to verify if the values are allowed.
|
|
|
|
*/
|
|
|
|
var url,
|
|
|
|
id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if URL is allowed
|
|
|
|
* URLs are allowed if they start with http://, https://, or /.
|
|
|
|
*/
|
2014-10-25 01:09:50 +04:00
|
|
|
url = function (url) {
|
|
|
|
// jscs:disable
|
|
|
|
url = url.toString().replace(/['"]+/g, '');
|
2014-07-25 14:42:42 +04:00
|
|
|
if (/^https?:\/\//.test(url) || /^\//.test(url)) {
|
|
|
|
return url;
|
|
|
|
}
|
2014-10-25 01:09:50 +04:00
|
|
|
// jscs:enable
|
2014-07-25 14:42:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if ID is allowed
|
|
|
|
* All ids are allowed at the moment.
|
|
|
|
*/
|
2014-10-25 01:09:50 +04:00
|
|
|
id = function (id) {
|
2014-07-25 14:42:42 +04:00
|
|
|
return id;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
url: url,
|
|
|
|
id: id
|
2014-10-25 01:09:50 +04:00
|
|
|
};
|