All files / ext.wikilambda.edit/mixins urlUtils.js

88.88% Statements 8/9
75% Branches 3/4
100% Functions 1/1
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25            13x     15x 15x 15x 15x 4x     11x       11x        
/*!
 * WikiLambda Vue URL manipulation utilities code
 *
 * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
 * @license MIT
 */
module.exports = exports = {
	methods: {
		getParameterByName: function ( name ) {
			name = name.replace( /[[]]/g, '\\$&' );
			var regex = new RegExp( '[?&]' + name + '(=([^&#]*)|&|#|$)' ),
				results = regex.exec( window.location.href );
			if ( !results ) {
				return null;
			}
 
			Iif ( !results[ 2 ] ) {
				return '';
			}
 
			return decodeURIComponent( results[ 2 ].replace( /\+/g, ' ' ) );
		}
	}
};