fix: drop the NUL byte from shortcutKey and add it to the default export - #1
Merged
Merged
Conversation
src/index.tsx held a literal U+0000 where shortcutKey builds its
separator, so every key came out as "id<NUL>{...}" instead of "id {...}".
That has two consequences:
* The byte reaches consumers. shortcutKey is documented public API and
the same string is baked into lib/module/index.js, so anything that
logs the key, stores it, or uses it as a React key carries a control
character it never asked for.
* Git classified src/index.tsx as binary, so every diff of the package
entry point rendered as "Binary files differ" and blame, grep and code
search all failed on it. That clears once this lands, because the new
blob is plain text.
shortcutKey is also added to the default export. README.md states that
every function is reachable both as a named export and on the default
export, and this was the one that was not, so
`import AppShortcuts from '@giabaojs/react-native-app-shortcuts'` followed
by `AppShortcuts.shortcutKey(item)` threw a TypeError.
Both are covered: one test asserts the key holds no control characters,
the other derives the expected default export from the module's own named
function exports so a later addition cannot silently drift again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The NUL byte
src/index.tsxline 42 contained a literalU+0000inside the templateliteral that
shortcutKey()builds its separator from, where a space wasclearly meant:
It looks like a space in an editor. It is not one.
It reaches users.
shortcutKeyis documented public API(
docs/API.md), andyarn preparecopies the byte straight intolib/module/index.js, which ismainand thedefaultexport condition.Every key handed back to a caller therefore carries a control character:
a problem for anything that logs it, JSON-encodes it, uses it as a React
key, or writes it to a store that rejects NUL bytes, such as a Postgres
textcolumn.It also made the entry point unreviewable. Git classified
src/index.tsxas binary (git ls-files --eolreportsi/-text w/-text),so any diff of the file rendered as Binary files differ, and
git blame,grepand GitHub code search all returned nothing for it. This PR's owndiff of that file still shows as binary because the parent blob is; it
renders as normal text from the next change onwards.
The fix is the single character that was intended.
shortcutKeymissing from the default exportREADME.mdstates that every function is reachable both as a named exportand on the default export.
shortcutKeywas the only one that was not, so:Tests
Two added to
src/__tests__/shortcuts.test.ts:a {"x":"1"};derived from the module itself rather than a hand-kept list, so a future
export cannot drift out of it unnoticed.
Both were confirmed to fail against the unfixed source, each against only
its own fix, and to pass once restored.
yarn lint,yarn typecheck,yarn testandyarn prepareare all green, and the rebuiltlib/module/index.jsno longer contains the byte.