Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

encoding: Reduce the number of replace calls while encoding URL.

100RABHpy62676e5a3d42
diff --git a/static/js/hash_util.js b/static/js/hash_util.js
index 84d595c57da..8ec879e8e85 100644
--- a/static/js/hash_util.js
+++ b/static/js/hash_util.js
@@ -27,13 +27,12 @@ export function get_hash_section(hash) {
// by replacing % with . (like MediaWiki).
export function encodeHashComponent(str) {
const characterToBeReplaced = {
+ ".": ".2E",
"%": ".",
"(": ".28",
")": ".29",
};
- return encodeURIComponent(str)
- .replace(/\./g, "%2E")
- .replace(/[%()]/g, (matched) => characterToBeReplaced[matched]);
+ return encodeURIComponent(str).replace(/[%().]/g, (matched) => characterToBeReplaced[matched]);
}
export function encode_operand(operator, operand) {