public static function encodePath($path)
	{
		$path = preg_replace_callback(
					'/(?:[^' . self::CHAR_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/u',
					__CLASS__ . '::urlEncodeChar',
					$path
				);

		if (empty($path))
			return null;	// No path

		if ($path[0] !== '/')
			return $path;	// Relative path

		// Ensure only one leading slash, to prevent XSS attempts.
		return '/' . ltrim($path, '/');
	}