diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-14 22:12:32 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-14 22:12:32 +0100 |
commit | 9d732da11731a0162839eca98b5de19f76e661a7 (patch) | |
tree | 1f53d7848d9c749374881f5f81ce433f03982ee7 /web/public | |
parent | 163d8e62433eb6d0d14910525d4900aab57de567 (diff) | |
download | taginfo-9d732da11731a0162839eca98b5de19f76e661a7.tar taginfo-9d732da11731a0162839eca98b5de19f76e661a7.tar.gz |
Improve regex for bad chars in url paths
Diffstat (limited to 'web/public')
-rw-r--r-- | web/public/js/taginfo.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index 5908c2d..8846898 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -195,9 +195,11 @@ function html_escape(text) { return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '''); } +var bad_chars_for_url = /[.=\/]/; + function url_for_key(key) { var k = encodeURIComponent(key); - if (key.match(/[=\/]/)) { + if (key.match(bad_chars_for_url)) { return '/keys/?key=' + k; } else { return '/keys/' + k; @@ -207,7 +209,7 @@ function url_for_key(key) { function url_for_tag(key, value) { var k = encodeURIComponent(key), v = encodeURIComponent(value); - if (key.match(/[=\/]/) || value.match(/[=\/]/)) { + if (key.match(bad_chars_for_url) || value.match(bad_chars_for_url)) { return '/tags/?key=' + k + '&value=' + v; } else { return '/tags/' + k + '=' + v; @@ -216,7 +218,7 @@ function url_for_tag(key, value) { function url_for_rtype(rtype) { var t = encodeURIComponent(rtype); - if (rtype.match(/[=\/]/)) { + if (rtype.match(bad_chars_for_url)) { return '/relations/?rtype=' + t; } else { return '/relations/' + t; |