<commit_before><?php
/**
* Static class to build URLs.
* I haven't really figured out a perfect method for this.
*/

namespace Neuron;




class URLBuilder 
{
	public static function getURL ($module = '', $data = array ())
	{
		if (substr ($module, 0, 1) === '/')
		{
			$module = substr ($module, 1);
		}

		$params = '';
		foreach ($data as $k => $v)
		{
			$params .= urlencode ($k) . '=' . urlencode ($v) . '&';
		}
		$params = substr ($params, 0, -1);

		if (!empty ($params))
		{
			return Config::get ('app.url', '/') . $module . '?' . $params;
		}
		else
		{
			// Google likes these.
			return Config::get ('app.url', '/') . $module;
		}
	}
}<commit_msg>Adding normalize & partify to URLBuilder.<commit_after><?php
/**
* Static class to build URLs.
* I haven't really figured out a perfect method for this.
*/

namespace Neuron;




class URLBuilder 
{
	public static function getURL ($module = '', $data = array (), $normalize = true)
	{
		if (substr ($module, 0, 1) === '/')
		{
			$module = substr ($module, 1);
		}

		$params = '';
		foreach ($data as $k => $v)
		{
			$params .= urlencode ($k) . '=' . urlencode ($v) . '&';
		}
		$params = substr ($params, 0, -1);

		if (!empty ($params))
		{
			if ($normalize)
				$url = self::normalize (Config::get ('app.url', '/') . $module) . '?' . $params;
			else
				$url = Config::get ('app.url', '/') . $module . '?' . $params;

			return $url;
		}
		else
		{
			// Google likes these.
			if ($normalize)
				return self::normalize (Config::get ('app.url', '/') . $module);
			else
				return Config::get ('app.url', '/') . $module;
		}
	}

	/**
	 * Make sure the string does not end with a /
	 * @param $path
	 * @return string
	 */
	public static function normalize ($path)
	{
		if (substr ($path, 0, -1) === '/')
		{
			return substr ($path, 0, -1);
		}
		return $path;
	}

	/**
	 * Make sure that the string ends with a slash.
	 * @param string $path
	 * @return string
	 */
	public static function partify ($path)
	{
		if (substr ($path, -1) !== '/')
		{
			return $path . '/';
		}
		return $path;
	}
}
{'fraction_non_alphanumeric': 0.20571151984511132, 'fraction_numerical': 0.007260406582768635, 'mean_word_length': 2.557659208261618, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7428966', 'n_tokens_mistral': 852, 'n_tokens_neox': 730, 'n_words': 218}