TypeError: $tw.utils.decodeURIComponentSafe is not a function

I followed the tutorial from https://tiddlywiki.com/#tiddlywiki.files%20Files to import a folder of PDFs. This is the content of my tiddlywiki.files file:

{
    "directories": [
        {
            "path": "../../files",
            "filesRegExp": "^.*\\.pdf$",
            "isTiddlerFile": false,
            "fields": {
                "title": {"source": "basename-uri-decoded", "prefix": "files/"},
                "created": {"source": "created"},
                "modified": {"source": "modified"},
                "type": "application/pdf",
                "tags": ["Source", "PDF"],
                "medium": "pdf",
                "text": "",
                "_canonical_uri": {"source": "filename", "prefix": "files/"}
            }
        }
    ]
}

However, when I start the node server (using TW version 5.2.0), I got the following error message in console:

C:\Users\Pak\AppData\Roaming\npm\node_modules\tiddlywiki\boot\boot.js:1903
                                                        value = $tw.utils.decodeURIComponentSafe(path.basename(filename,path.extname(filename)));
                                                                          ^

TypeError: $tw.utils.decodeURIComponentSafe is not a function
    at C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1903:26
    at Object.$tw.utils.each (C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:135:12)
    at C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1887:14
    at Object.$tw.utils.each (C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:126:12)
    at processFile (C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1886:13)
    at C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1960:7
    at Object.$tw.utils.each (C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:126:12)
    at Object.$tw.loadTiddlersFromSpecification (C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1943:12)
    at Object.$tw.loadTiddlersFromPath (C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1847:45)
    at C:\Users\Pak\AppData\Roaming\npm\node_modules\←[4mtiddlywiki←[24m\boot\boot.js:1852:40

I believe the cause is due to the line "title": {"source": "basename-uri-decoded",... since when I change from basename-uri-decoded to basename or filename then everything works fine and I see the imported PDFs. But when I use xxxx-uri-decoded then the server doesn’t start and I got the above error message in console.

Does anyone else have this problem? Is it just my computer or is it really a bug?

Would you be happy with an interactive method to import a whole folder of PDF’s at once?

Use the browse widget with multiple and select all PDF’s in the folder.

<$browse multiple/>

I suspect this is a bug in 5.2.0 related to this change:

<$browse multiple/>

Thanks for the tip. I have not heard of that widget before. It’s quite useful. I can get it to work with basename only. However I wasn’t sure why I have error when using basename-uri-decoded so I want to check if it’s just my installation or if it’s a known bug.

I suspect this is a bug in 5.2.0 related to this change:

Ahh that might make sense. I used to be able to do this before I upgraded to 5.2.0.

I’ve looked at the check-in and these functions have been defined in core/modules/utils/utils.js and so are not defined when the bootloader first runs.

Very good catch, I had not tried all the various tiddlywiki.files options with that change, as it was targeted at preventing server-crashes as it was running. We have an Issue tracking this on GitHub.