summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-07-16 12:40:46 -0400
committerLinus Groh <mail@linusgroh.de>2021-07-17 16:59:59 +0100
commit87848cdf7d66e76da1331477ffa73a0141d480d7 (patch)
tree32e2f1e894b15430a060f3ed7bf4d7f5970ded9b /Userland/Libraries
parent660a8982e79fc4a0223ee7e94034f47789383803 (diff)
downloadserenity-87848cdf7d66e76da1331477ffa73a0141d480d7.zip
AK: Track byte length, rather than code point length, in Utf8View::trim
Utf8View::trim uses Utf8View::substring_view to return its result, which requires the input to be a byte offset/length rather than code point length.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/String/String.prototype.trim.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/String/String.prototype.trim.js b/Userland/Libraries/LibJS/Tests/builtins/String/String.prototype.trim.js
index d60522cad4..d5f7a0bec0 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/String/String.prototype.trim.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/String/String.prototype.trim.js
@@ -56,3 +56,9 @@ test("trimEnd", () => {
expect("\r\nhello friends".trimEnd()).toBe("\r\nhello friends");
expect("\rhello friends\r\n".trimEnd()).toBe("\rhello friends");
});
+
+test("multi-byte code point", () => {
+ expect("_\u180E".trim()).toBe("_\u180E");
+ expect("\u180E".trim()).toBe("\u180E");
+ expect("\u180E_".trim()).toBe("\u180E_");
+});