added a function to strictly encode uri components.
--- a/src/js/utils.js Wed Nov 30 17:27:12 2011 +0100
+++ b/src/js/utils.js Thu Dec 01 11:40:35 2011 +0100
@@ -103,6 +103,15 @@
return Mustache.to_html(template, params);
};
+/* we need to be stricter than encodeURIComponent,
+ because of twitter
+*/
+IriSP.encodeURI = function(str) {
+ return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
+ replace(/\)/g, '%29').replace(/\*/g, '%2A');
+}
+
+
/* for ie compatibility
if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
Object.defineProperty=function(obj,prop,desc) {
--- a/unittests/tests/utils.js Wed Nov 30 17:27:12 2011 +0100
+++ b/unittests/tests/utils.js Thu Dec 01 11:40:35 2011 +0100
@@ -57,4 +57,8 @@
IriSP.default_templates_vars["test_fixture"] = "FIXTURE";
equal(IriSP.templToHTML("{{test_fixture}} {{foo}}", {foo: 2}), "FIXTURE 2", "correct template returned");
});
+
+ test("test url encoding function", function() {
+ equal(IriSP.encodeURI("!'()*"), "%21%27%28%29%2A", "the returned string is correct");
+ });
}