Skip to content

Commit

Permalink
Remove bloated filename from content type it isn't worth the extra pa…
Browse files Browse the repository at this point in the history
…ckage size increase for such an unused feature.
  • Loading branch information
wparad committed Aug 30, 2023
1 parent f329342 commit b3022a7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 54 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"lodash.clonedeep": "^4.5.0",
"lodash.merge": "^4.6.2",
"marked": "^4.0.16",
"mime-db": "^1.52.0",
"openapi-data-validator": "^2.0.40",
"openapi-resolver": "^4.1.35",
"prismjs": "^1.29.0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/api-request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LitElement, html } from 'lit';
import { marked } from 'marked';
import mimeTypeResolver from './mime-types.js';

import { unsafeHTML } from 'lit/directives/unsafe-html.js';
import { keyed } from 'lit/directives/keyed.js';
Expand Down Expand Up @@ -999,7 +998,7 @@ export default class ApiRequest extends LitElement {
const contentDisposition = fetchResponse.headers.get('content-disposition');
const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
const filename = filenameRegex.exec(contentDisposition);
this.respContentDisposition = filename && filename[1] && filename[1].replace(/['"]/g, '') || `download.${await mimeTypeResolver(contentType) || 'file'}`;
this.respContentDisposition = filename?.[1]?.replace(/['"]/g, '') || 'download.file';
respBlob = await fetchResponse.blob();
this.responseBlobUrl = URL.createObjectURL(respBlob);
}
Expand Down
50 changes: 0 additions & 50 deletions src/components/mime-types.js

This file was deleted.

2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5194,7 +5194,7 @@ micromatch@^4.0.2, micromatch@^4.0.4:
braces "^3.0.2"
picomatch "^2.3.1"

[email protected], "mime-db@>= 1.43.0 < 2", mime-db@^1.52.0:
[email protected], "mime-db@>= 1.43.0 < 2":
version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
Expand Down

0 comments on commit b3022a7

Please sign in to comment.