| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9138b78 commit 7b9adff
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3079,10 +3079,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) { | |||
| 3079 | 3079 | return; | |
| 3080 | 3080 | } | |
| 3081 | 3081 | ||
| 3082 | - std::string err_module_message = | ||
| 3083 | - "Cannot find package '" + module_path + "' imported from " + module_base; | ||
| 3084 | 3082 | env->isolate()->ThrowException( | |
| 3085 | - ERR_MODULE_NOT_FOUND(env->isolate(), err_module_message.c_str())); | ||
| 3083 | + ERR_MODULE_NOT_FOUND(env->isolate(), | ||
| 3084 | + "Cannot find package '%s' imported from %s", | ||
| 3085 | + module_path, | ||
| 3086 | + module_base)); | ||
| 3086 | 3087 | } | |
| 3087 | 3088 | ||
| 3088 | 3089 | void BindingData::MemoryInfo(MemoryTracker* tracker) const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,14 @@ describe('legacyMainResolve', () => { | |||
| 133 | 133 | ); | |
| 134 | 134 | }); | |
| 135 | 135 | ||
| 136 | + it('should not crash when cannot resolve to a file that contains special chars', () => { | ||
| 137 | + const packageJsonUrl = pathToFileURL('/c/file%20with%20percents/package.json'); | ||
| 138 | + assert.throws( | ||
| 139 | + () => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl), | ||
| 140 | + { code: 'ERR_MODULE_NOT_FOUND' }, | ||
| 141 | + ); | ||
| 142 | + }); | ||
| 143 | + | ||
| 136 | 144 | it('should throw when cannot resolve to a file (base not defined)', () => { | |
| 137 | 145 | const packageJsonUrl = pathToFileURL( | |
| 138 | 146 | path.resolve( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments