[geary/mjog/558-webkit-shared-process-redux: 100/102] Util.JS: Remove now-unused code




commit 0609fbc3d7cec05a4e5fbf4c5ca9377ea802344b
Author: Michael Gratton <mike vee net>
Date:   Fri Aug 28 12:06:36 2020 +1000

    Util.JS: Remove now-unused code

 src/client/util/util-js.vala       | 50 --------------------------------------
 test/client/util/util-js-test.vala | 11 ---------
 2 files changed, 61 deletions(-)
---
diff --git a/src/client/util/util-js.vala b/src/client/util/util-js.vala
index 095f9da41..193b3c7ab 100644
--- a/src/client/util/util-js.vala
+++ b/src/client/util/util-js.vala
@@ -364,56 +364,6 @@ namespace Util.JS {
         return value;
     }
 
-    /**
-     * Escapes a string so as to be safe to use as a JS string literal.
-     *
-     * This does not append opening or closing quotes.
-     */
-    public string escape_string(string value) {
-        StringBuilder builder = new StringBuilder.sized(value.length);
-        for (int i = 0; i < value.length; i++) {
-            if (value.valid_char(i)) {
-                unichar c = value.get_char(i);
-                switch (c) {
-                case '\x00':
-                    builder.append("\x00");
-                    break;
-                case '\'':
-                    builder.append("\\\'");
-                    break;
-                case '"':
-                    builder.append("\\\"");
-                    break;
-                case '\\':
-                    builder.append("\\\\");
-                    break;
-                case '\n':
-                    builder.append("\\n");
-                    break;
-                case '\r':
-                    builder.append("\\r");
-                    break;
-                case '\x0b':
-                    builder.append("\x0b");
-                    break;
-                case '\t':
-                    builder.append("\\t");
-                    break;
-                case '\b':
-                    builder.append("\\b");
-                    break;
-                case '\f':
-                    builder.append("\\f");
-                    break;
-                default:
-                    builder.append_unichar(c);
-                    break;
-                }
-            }
-        }
-        return (string) builder.data;
-    }
-
     /**
      * Convenience method for returning a new Callable instance.
      */
diff --git a/test/client/util/util-js-test.vala b/test/client/util/util-js-test.vala
index f1da043d7..9fea3cd7a 100644
--- a/test/client/util/util-js-test.vala
+++ b/test/client/util/util-js-test.vala
@@ -13,7 +13,6 @@ public class Util.JS.Test : TestCase {
 
     public Test() {
         base("Util.JS.Test");
-        add_test("escape_string", escape_string);
         add_test("to_variant", to_variant);
         add_test("to_value", to_value);
     }
@@ -26,16 +25,6 @@ public class Util.JS.Test : TestCase {
         this.context = null;
     }
 
-    public void escape_string() throws GLib.Error {
-        assert(Util.JS.escape_string("\n") == """\n""");
-        assert(Util.JS.escape_string("\r") == """\r""");
-        assert(Util.JS.escape_string("\t") == """\t""");
-        assert(Util.JS.escape_string("\'") == """\'""");
-        assert(Util.JS.escape_string("\"") == """\"""");
-
-        assert(Util.JS.escape_string("something…\n") == """something…\n""");
-    }
-
     public void to_variant() throws GLib.Error {
         assert_equal(
             value_to_variant(new JSC.Value.null(this.context)).print(true),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]