itty-bitty
itty-bitty copied to clipboard
atob decoding failure in recordToHistory
This simple url seems to work: https://itty.bitty.site/#/data:text/plain;charset=utf-8,hello%20world. However, I see this exception in the console:
bitty.js:87 Uncaught (in promise) DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at get href [as href] (https://itty.bitty.site/bitty.js:87:27)
at recordToHistory (https://itty.bitty.site/index.js:501:42)
at renderContent (https://itty.bitty.site/index.js:412:37)
After stepping through the debugger, it looks to be that durl.href
is not a well-behaved getter. It is modifying state (this.dataPrefix
):
https://github.com/alcor/itty-bitty/blob/afe37fa0b34610c6f179a9b184a5d0e2a7c836fd/docs/bitty.js#L79-L91
That means the first time the href getter is called, the dataPrefix will be modified to its decoded value: https://github.com/alcor/itty-bitty/blob/afe37fa0b34610c6f179a9b184a5d0e2a7c836fd/docs/index.js#L388
Then the second time it is called it will fail to decode since it is already decoded: https://github.com/alcor/itty-bitty/blob/afe37fa0b34610c6f179a9b184a5d0e2a7c836fd/docs/index.js#L412
Maybe the href
getter should use a local variable to store the decoded dataPrefix?