Files
ulthon_admin/app/admin/view/xhprof/watch/add.js

41 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(function(){
// PCRE 正则前端预校验:必须带定界符(权威校验在后端 @preg_match
var form = window.UA_CORE.form;
if (form) {
form.verify({
watchRegex: function (value) {
value = $.trim(value);
if (value === '') {
return '正则不能为空';
}
var delim = value.charAt(0);
if (/[a-zA-Z0-9\s\\]/.test(delim)) {
return '必须带 PCRE 定界符,如 ~think\\db\\.*~';
}
var body = value.substring(1);
var closeIdx = -1;
for (var i = 0; i < body.length; i++) {
var c = body.charAt(i);
if (c === '\\') {
i++;
continue;
}
if (c === delim) {
closeIdx = i;
break;
}
}
if (closeIdx === -1) {
return '找不到闭合定界符 ' + delim;
}
var modifiers = body.substring(closeIdx + 1);
if (!/^[imsxADSUXJu]*$/.test(modifiers)) {
return '非法修饰符:' + modifiers;
}
},
});
}
ua.listen();
})