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(client): better handle content types #195

Merged
merged 1 commit into from
Mar 31, 2024

Conversation

jordanshatford
Copy link
Collaborator

Better handle more content types based on: https://www.iana.org/assignments/media-types/media-types.xhtml

ref: #152 (pdf content type as binary)

Copy link

codecov bot commented Mar 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.70%. Comparing base (60f044b) to head (df22d0a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #195   +/-   ##
=======================================
  Coverage   90.70%   90.70%           
=======================================
  Files          66       66           
  Lines        4000     4000           
  Branches      477      477           
=======================================
  Hits         3628     3628           
  Misses        371      371           
  Partials        1        1           
Flag Coverage Δ
unittests 90.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1,6 +1,6 @@
export const getRequestBody = (options: ApiRequestOptions): unknown => {
if (options.body) {
if (options.mediaType?.includes('/json')) {
if (options.mediaType?.includes('application/json') || options.mediaType?.includes('+json')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make this just endsWith('json')?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may not always end with json, as there may be charset information in the header. JSON with always be application/json or something/something+json (but may be appended by "; charset=utf8")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about includes json then? Why not drop + and /?

@jordanshatford jordanshatford merged commit a8a164d into main Mar 31, 2024
14 checks passed
@jordanshatford jordanshatford deleted the feat/better-content-type-handling branch March 31, 2024 23:34
@github-actions github-actions bot mentioned this pull request Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants