| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 64a8843 commit 3126ce5
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -841,7 +841,7 @@ void GetAsset(const FunctionCallbackInfo<Value>& args) { | |||
| 841 | 841 | if (sea_resource.assets.empty()) { | |
| 842 | 842 | return; | |
| 843 | 843 | } | |
| 844 | - auto it = sea_resource.assets.find(*key); | ||
| 844 | + auto it = sea_resource.assets.find(std::string_view(*key, key.length())); | ||
| 845 | 845 | if (it == sea_resource.assets.end()) { | |
| 846 | 846 | return; | |
| 847 | 847 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,8 @@ | |||
| 2 | 2 | "main": "sea.js", | |
| 3 | 3 | "output": "sea-prep.blob", | |
| 4 | 4 | "assets": { | |
| 5 | + "a": "utf8_test_text.txt", | ||
| 6 | + "a\u0000b": "person.jpg", | ||
| 5 | 7 | "utf8_test_text.txt": "utf8_test_text.txt", | |
| 6 | 8 | "person.jpg": "person.jpg" | |
| 7 | 9 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,12 @@ assert(isSea()); | |||
| 54 | 54 | const textAssetOnDisk = readFileSync(process.env.__TEST_UTF8_TEXT_PATH, 'utf8'); | |
| 55 | 55 | const binaryAssetOnDisk = readFileSync(process.env.__TEST_PERSON_JPG); | |
| 56 | 56 | ||
| 57 | + // Check asset keys containing NUL. | ||
| 58 | + { | ||
| 59 | + assert.strictEqual(getAsset('a', 'utf8'), textAssetOnDisk); | ||
| 60 | + assert.deepStrictEqual(Buffer.from(getAsset('a\0b')), binaryAssetOnDisk); | ||
| 61 | + } | ||
| 62 | + | ||
| 57 | 63 | // Check getAsset() buffer copies. | |
| 58 | 64 | { | |
| 59 | 65 | // Check that the asset embedded is the same as the original. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments