jsTodoTxt icon indicating copy to clipboard operation
jsTodoTxt copied to clipboard

Special characters throw error in Items.ts

Open ransome1 opened this issue 2 years ago • 4 comments

Hi.

Over at the sleek project, I switched to the next branch and by coincidence stumbled upon something you might be interested in.

If you try to parse some special characters like a Carriage return (\r) or Line Feed (\n) or even both (\r\n), this will throw an error in Item.ts at line 128.

TypeError: Cannot read properties of null (reading '2')
    at Item.parse (/Users/ransome/Development/sleek/node_modules/jstodotxt/src/Item.ts:128:25)
    at new Item (/Users/ransome/Development/sleek/node_modules/jstodotxt/src/Item.ts:106:8)

The old implementation is able to work with it. Hope it helps.

ransome1 avatar Sep 14 '23 08:09 ransome1

@ransome1 I know this is a pretty ancient ticket, but what would the preference be here?

There is the List class for handling multiline input, but what should a single line constructor like Item do in this case? I think it's either:

  1. Throw an error
  2. Truncate input at the first newline characters

I lean towards 1, as 2 could be confusing and hide bugs/mangle data

jmhobbs avatar Jan 17 '25 04:01 jmhobbs

@jmhobbs is there a documentation about the List class? I can only find stuff about the Item class. This is where I am looking at: https://jstodotxt.velvetcache.org/modules

ransome1 avatar Jan 18 '25 13:01 ransome1

@ransome1 I'm not sure 🤔

The last PR deploy preview has it, so not sure why it did not pick it up on merge.

jmhobbs avatar Jan 19 '25 22:01 jmhobbs

It was hooked up to latest (a branch which doesn't exist).

Should be fixed now and deploying, out shortly.

jmhobbs avatar Jan 19 '25 22:01 jmhobbs