mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	hash_util: Show error if url is invalid.
For urls we cannot handle, we inform user via a nice error message. See comment in decodeHashComponent for some of the cases it fixes for us.
This commit is contained in:
		@@ -56,7 +56,18 @@ exports.encode_stream_name = function (operand) {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.decodeHashComponent = function (str) {
 | 
			
		||||
    return decodeURIComponent(str.replace(/\./g, '%'));
 | 
			
		||||
    try {
 | 
			
		||||
        // This fails for URLS containing
 | 
			
		||||
        // foo.foo or foo%foo due to our fault in special handling
 | 
			
		||||
        // of such characters when encoding. This can also,
 | 
			
		||||
        // fail independent of our fault, so just tell the user
 | 
			
		||||
        // that the url is invalid.
 | 
			
		||||
        // TODO: Show possible valid urls to the user.
 | 
			
		||||
        return decodeURIComponent(str.replace(/\./g, '%'));
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
        ui_report.error(i18n.t("Invalid URL"), undefined, $("#home-error"), 2000);
 | 
			
		||||
        return "";
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.decode_operand = function (operator, operand) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user