Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to undici v7 #547

Merged
merged 10 commits into from
Nov 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
f
fengmk2 committed Nov 29, 2024
commit 12c7b229247be149322d03367396cdefe1f8923d
15 changes: 15 additions & 0 deletions test/options.files.test.ts
Original file line number Diff line number Diff line change
@@ -36,6 +36,21 @@ describe('options.files.test.ts', () => {
assert.equal(response.data.files.file.size, stat.size);
});

it('should upload not exists file throw error', async () => {
const file = path.join(__dirname, 'cjs', 'index.js-not-exists');
await assert.rejects(async () => {
await urllib.request(`${_url}multipart`, {
files: [ file ],
dataType: 'json',
});
}, (err: any) => {
assert.equal(err.code, 'ENOENT');
assert.equal(err.res.status, -1);
assert.equal(err.status, -1);
return true;
});
});

it('should upload files = [filepath] success with default POST method', async () => {
const file = path.join(__dirname, 'cjs', 'index.js');
const stat = await fs.stat(file);

Unchanged files with check annotations Beta

export function fetchOpaqueInterceptor(opts: OpaqueInterceptorOptions) {
const opaqueLocalStorage = opts?.opaqueLocalStorage;
return (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch'] => {
return function redirectInterceptor(opts: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler) {

Check warning on line 35 in src/FetchOpaqueInterceptor.ts

Codecov / codecov/patch

src/FetchOpaqueInterceptor.ts#L35

Added line #L35 was not covered by tests
const opaque = opaqueLocalStorage?.getStore();
(handler as any).opaque = opaque;
return dispatch(opts, handler);
if (typeof options.filepath === 'string') {
// custom filepath for relative paths
filename = path.normalize(options.filepath).replace(/\\/g, '/');

Check warning on line 13 in src/FormData.ts

Codecov / codecov/patch

src/FormData.ts#L13

Added line #L13 was not covered by tests
} else if (options.filename || value.name || value.path) {
// custom filename take precedence
// formidable and the browser add a name property
filename = path.basename(options.filename || value.name || value.path);
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
// or try http response
filename = path.basename(value.client._httpMessage.path || '');
}

Check warning on line 22 in src/FormData.ts

Codecov / codecov/patch

src/FormData.ts#L21-L22

Added lines #L21 - L22 were not covered by tests
if (filename) {
// https://datatracker.ietf.org/doc/html/rfc6266#section-4.1