<commit_before>( function( mw, $ ) { "use strict";

mw.AdLoader = {
	// Vast response can return Wrapper that points to another vast
	// this varible holds the max number of redirects to follow
	maxRedirects: 5,
	currentCounter: 0,
	/**
	 * Get ad display configuration object from a url
	 *
	 * @param {string} adUrl
	 * 		The url which contains the xml ad payload
	 * @param {function} callback
	 * 		Function called with ad payload once ad content is loaded.
	 * @param {boolean} wrapped
	 * 		(optional) used to increase the internal counter
	 * @param {XML} wrapperData
	 * 		(optional) in case this loader is being called from a wrapper, preserve the wrapper data and pass it to the
     * 		inner ad so it can parse and send its events
	 * @param {object} ajaxOptions
	 * 		(optional) additional ajax options, e.g. withCredentials
	 */
	load: function( adUrl, callback, wrapped , wrapperData, ajaxOptions ){
		var _this = this;
        this.wrapperData = null;

		adUrl = _this.replaceCacheBuster(adUrl);
		
		// trip whitespace in ad urls: 
		adUrl = $.trim( adUrl );
		
		mw.log('AdLoader :: load Ad: ', adUrl);

		// Increase counter if the vast is wrapped, otherwise reset
		if( wrapped ) {
            this.wrapperData = wrapperData ;
			this.currentCounter++;
		} else {
			this.currentCounter = 0;
		}

		// Stop loading of ad if the counter is bigger then max redirects<commit_msg>SUP-3290 #time 2h #comment apply encodeURIComponent to the adUrl before loading it<commit_after>( function( mw, $ ) { "use strict";

mw.AdLoader = {
	// Vast response can return Wrapper that points to another vast
	// this varible holds the max number of redirects to follow
	maxRedirects: 5,
	currentCounter: 0,
	/**
	 * Get ad display configuration object from a url
	 *
	 * @param {string} adUrl
	 * 		The url which contains the xml ad payload
	 * @param {function} callback
	 * 		Function called with ad payload once ad content is loaded.
	 * @param {boolean} wrapped
	 * 		(optional) used to increase the internal counter
	 * @param {XML} wrapperData
	 * 		(optional) in case this loader is being called from a wrapper, preserve the wrapper data and pass it to the
     * 		inner ad so it can parse and send its events
	 * @param {object} ajaxOptions
	 * 		(optional) additional ajax options, e.g. withCredentials
	 */
	load: function( adUrl, callback, wrapped , wrapperData, ajaxOptions ){
		var _this = this;
        this.wrapperData = null;

		adUrl = _this.replaceCacheBuster(adUrl);
		
		// trip whitespace in ad urls: 
		adUrl = $.trim( adUrl );

		try{
			adUrl = encodeURIComponent(adUrl);
		}catch(e){
			mw.log('AdLoader :: Error when trying to apply encodeURIComponent to adUrl: '+ e.message);
		}

		mw.log('AdLoader :: load Ad: ', adUrl);

		// Increase counter if the vast is wrapped, otherwise reset
		if( wrapped ) {
            this.wrapperData = wrapperData ;
			this.currentCounter++;
		} else {
			this.currentCounter = 0;
		}

		// Stop loading of ad if the counter is bigger then max redirects
{'fraction_non_alphanumeric': 0.09084880636604775, 'fraction_numerical': 0.003647214854111406, 'mean_word_length': 3.1786703601108033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5703043', 'n_tokens_mistral': 972, 'n_tokens_neox': 865, 'n_words': 362}