mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
Fix encoding of narrows with '.' in the URIs.
(imported from commit fa624c0f810817b8093aeb4e3fb4329cad4cf9fb)
This commit is contained in:
@@ -9,11 +9,11 @@ var changing_hash = false;
|
|||||||
// window.location.hash. So we hide our URI-encoding
|
// window.location.hash. So we hide our URI-encoding
|
||||||
// by replacing % with . (like MediaWiki).
|
// by replacing % with . (like MediaWiki).
|
||||||
|
|
||||||
function encodeHashComponent(str) {
|
exports.encodeHashComponent = function(str) {
|
||||||
return encodeURIComponent(str)
|
return encodeURIComponent(str)
|
||||||
.replace(/\./g, '%2E')
|
.replace(/\./g, '%2E')
|
||||||
.replace(/%/g, '.');
|
.replace(/%/g, '.');
|
||||||
}
|
};
|
||||||
|
|
||||||
function decodeHashComponent(str) {
|
function decodeHashComponent(str) {
|
||||||
return decodeURIComponent(str.replace(/\./g, '%'));
|
return decodeURIComponent(str.replace(/\./g, '%'));
|
||||||
@@ -45,8 +45,8 @@ exports.save_narrow = function (operators) {
|
|||||||
} else {
|
} else {
|
||||||
var new_hash = '#narrow';
|
var new_hash = '#narrow';
|
||||||
$.each(operators, function (idx, elem) {
|
$.each(operators, function (idx, elem) {
|
||||||
new_hash += '/' + encodeHashComponent(elem[0])
|
new_hash += '/' + hashchange.encodeHashComponent(elem[0])
|
||||||
+ '/' + encodeHashComponent(elem[1]);
|
+ '/' + hashchange.encodeHashComponent(elem[1]);
|
||||||
});
|
});
|
||||||
exports.changehash(new_hash);
|
exports.changehash(new_hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ function create_sub(stream_name, attrs) {
|
|||||||
|
|
||||||
add_sub(stream_name, sub);
|
add_sub(stream_name, sub);
|
||||||
if (sub.subscribed) {
|
if (sub.subscribed) {
|
||||||
ui.add_narrow_filter(stream_name, "stream", "#narrow/stream/" + encodeURIComponent(stream_name));
|
ui.add_narrow_filter(stream_name, "stream", "#narrow/stream/" + hashchange.encodeHashComponent(stream_name));
|
||||||
}
|
}
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ function mark_subscribed(stream_name, attrs) {
|
|||||||
set_color(stream_name, pick_color());
|
set_color(stream_name, pick_color());
|
||||||
mark_color_used(sub.color);
|
mark_color_used(sub.color);
|
||||||
// This will do nothing on MIT
|
// This will do nothing on MIT
|
||||||
ui.add_narrow_filter(stream_name, "stream", "#narrow/stream/" + encodeURIComponent(stream_name));
|
ui.add_narrow_filter(stream_name, "stream", "#narrow/stream/" + hashchange.encodeHashComponent(stream_name));
|
||||||
var settings = settings_for_sub(sub);
|
var settings = settings_for_sub(sub);
|
||||||
var button = button_for_sub(sub);
|
var button = button_for_sub(sub);
|
||||||
if (button.length !== 0) {
|
if (button.length !== 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user