Skip to content

Commit 2d861a3

Browse files
authored
Improve the regex and add tests to prove it works (#383)
1 parent 400ec52 commit 2d861a3

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

dap-launch.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ supported."
4141
(or (: "//" (* nonl) eol)
4242
(: "/*" (* (or (not (any ?*))
4343
(: (+ ?*) (not (any ?/))))) (+ ?*) ?/)
44-
(: "," (group (* (any blank ?\C-j)) (any ?\} ?\])))))
44+
(: "," (group (* (any blank space ?\v ?\u2028 ?\u2029))
45+
(any ?\} ?\])))))
4546
(: "\"" (* (or (not (any ?\\ ?\")) (: ?\\ nonl))) "\"")))
4647
nil t)
4748
;; we matched a comment

test/dap-test.el

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,26 @@
149149

150150
(ert-deftest dap-launch-test--delete-commas ()
151151
(let* ((orig "{
152-
\"abc\": 123,
152+
\"conf\": [
153+
{
154+
\"a\": \"b\",\t\v\u00A0
155+
},
156+
{
157+
\"b\": \"c\",\xD\u2028\u2029
158+
},\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006
159+
],\u2007\u2008\u2009\u200A\u202F\u205F\u3000
153160
}")
154-
(post-exp (dap-launch-test--sanitize-json orig)))
155-
(should (string= post-exp "{
156-
\"abc\": 123
157-
}"))))
161+
(expected "{
162+
\"conf\": [
163+
{
164+
\"a\": \"b\"\t\v\u00A0
165+
},
166+
{
167+
\"b\": \"c\"\xD\u2028\u2029
168+
}\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006
169+
]\u2007\u2008\u2009\u200A\u202F\u205F\u3000
170+
}"))
171+
(should (string= (dap-launch-test--sanitize-json orig) expected))))
158172

159173
(ert-deftest dap-launch-test--comment-in-string ()
160174
(let ((orig "\"// orig\""))

0 commit comments

Comments
 (0)