mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	Simplified Regex usage in JS
Follows 70752b0fc1dde9a32d3565759d77072d3187f4eb
This commit is contained in:
		@ -208,8 +208,7 @@ window.yii = (function ($) {
 | 
			
		||||
 | 
			
		||||
            var newForm = !$form.length;
 | 
			
		||||
            if (newForm) {
 | 
			
		||||
                var regexp = /(^\/|:\/\/)/;
 | 
			
		||||
                if (!action || !regexp.test(action)) {
 | 
			
		||||
                if (!action || !/(^\/|:\/\/)/.test(action)) {
 | 
			
		||||
                    action = window.location.href;
 | 
			
		||||
                }
 | 
			
		||||
                $form = $('<form/>', {method: method, action: action});
 | 
			
		||||
@ -217,13 +216,11 @@ window.yii = (function ($) {
 | 
			
		||||
                if (target) {
 | 
			
		||||
                    $form.attr('target', target);
 | 
			
		||||
                }
 | 
			
		||||
                regexp = /(get|post)/i;
 | 
			
		||||
                if (!regexp.test(method)) {
 | 
			
		||||
                if (!/(get|post)/i.test(method)) {
 | 
			
		||||
                    $form.append($('<input/>', {name: '_method', value: method, type: 'hidden'}));
 | 
			
		||||
                    method = 'POST';
 | 
			
		||||
                }
 | 
			
		||||
                regexp = /(get|head|options)/i;
 | 
			
		||||
                if (!regexp.test(method)) {
 | 
			
		||||
                if (!/(get|head|options)/i.test(method)) {
 | 
			
		||||
                    var csrfParam = pub.getCsrfParam();
 | 
			
		||||
                    if (csrfParam) {
 | 
			
		||||
                        $form.append($('<input/>', {name: csrfParam, value: pub.getCsrfToken(), type: 'hidden'}));
 | 
			
		||||
 | 
			
		||||
@ -225,16 +225,14 @@ yii.validation = (function ($) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var regexp = /:\/\//;
 | 
			
		||||
            if (options.defaultScheme && !regexp.test(value)) {
 | 
			
		||||
            if (options.defaultScheme && !/:\/\//.test(value)) {
 | 
			
		||||
                value = options.defaultScheme + '://' + value;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var valid = true;
 | 
			
		||||
 | 
			
		||||
            if (options.enableIDN) {
 | 
			
		||||
                regexp = /^([^:]+):\/\/([^\/]+)(.*)$/;
 | 
			
		||||
                matches = regexp.exec(value);
 | 
			
		||||
                var matches = /^([^:]+):\/\/([^\/]+)(.*)$/.exec(value);
 | 
			
		||||
                if (matches === null) {
 | 
			
		||||
                    valid = false;
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user