mirror of
https://github.com/LukeHagar/sveltekit-adapters.git
synced 2025-12-06 04:21:32 +00:00
Merge pull request #14 from LukeHagar/add-mrmime
This commit is contained in:
6182
package-lock.json
generated
Normal file
6182
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
|||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
|
import { lookup } from 'mrmime';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import isDev from 'electron-is-dev';
|
import isDev from 'electron-is-dev';
|
||||||
import { protocol, net, dialog } from 'electron';
|
import { protocol, net, dialog } from 'electron';
|
||||||
@@ -365,39 +366,7 @@ export const fileExists = async (filePath) => {
|
|||||||
*/
|
*/
|
||||||
export function getMimeType(filePath) {
|
export function getMimeType(filePath) {
|
||||||
const ext = path.extname(filePath).toLowerCase();
|
const ext = path.extname(filePath).toLowerCase();
|
||||||
const mimeTypes = {
|
return lookup(ext) || 'application/octet-stream';
|
||||||
'.html': 'text/html',
|
|
||||||
'.htm': 'text/html',
|
|
||||||
'.js': 'application/javascript',
|
|
||||||
'.mjs': 'application/javascript',
|
|
||||||
'.css': 'text/css',
|
|
||||||
'.json': 'application/json',
|
|
||||||
'.png': 'image/png',
|
|
||||||
'.jpg': 'image/jpeg',
|
|
||||||
'.jpeg': 'image/jpeg',
|
|
||||||
'.gif': 'image/gif',
|
|
||||||
'.svg': 'image/svg+xml',
|
|
||||||
'.ico': 'image/x-icon',
|
|
||||||
'.woff': 'font/woff',
|
|
||||||
'.woff2': 'font/woff2',
|
|
||||||
'.ttf': 'font/ttf',
|
|
||||||
'.eot': 'application/vnd.ms-fontobject',
|
|
||||||
'.otf': 'font/otf',
|
|
||||||
'.webp': 'image/webp',
|
|
||||||
'.avif': 'image/avif',
|
|
||||||
'.mp4': 'video/mp4',
|
|
||||||
'.webm': 'video/webm',
|
|
||||||
'.mp3': 'audio/mpeg',
|
|
||||||
'.wav': 'audio/wav',
|
|
||||||
'.pdf': 'application/pdf',
|
|
||||||
'.zip': 'application/zip',
|
|
||||||
'.txt': 'text/plain',
|
|
||||||
'.md': 'text/markdown',
|
|
||||||
'.xml': 'application/xml',
|
|
||||||
'.csv': 'text/csv'
|
|
||||||
};
|
|
||||||
|
|
||||||
return mimeTypes[ext] || 'application/octet-stream';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
"cookie": "^0.6.0",
|
"cookie": "^0.6.0",
|
||||||
"electron": "^28.0.0",
|
"electron": "^28.0.0",
|
||||||
"electron-is-dev": "^3.0.1",
|
"electron-is-dev": "^3.0.1",
|
||||||
|
"mrmime": "^2.0.1",
|
||||||
"rollup": "^4.45.1",
|
"rollup": "^4.45.1",
|
||||||
"set-cookie-parser": "^2.6.0"
|
"set-cookie-parser": "^2.6.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ describe('Protocol Handler Utils', () => {
|
|||||||
it('should return correct MIME types for common file extensions', () => {
|
it('should return correct MIME types for common file extensions', () => {
|
||||||
expect(getMimeType('file.html')).toBe('text/html');
|
expect(getMimeType('file.html')).toBe('text/html');
|
||||||
expect(getMimeType('file.htm')).toBe('text/html');
|
expect(getMimeType('file.htm')).toBe('text/html');
|
||||||
expect(getMimeType('file.js')).toBe('application/javascript');
|
expect(getMimeType('file.js')).toBe('text/javascript');
|
||||||
expect(getMimeType('file.mjs')).toBe('application/javascript');
|
expect(getMimeType('file.mjs')).toBe('text/javascript');
|
||||||
expect(getMimeType('file.css')).toBe('text/css');
|
expect(getMimeType('file.css')).toBe('text/css');
|
||||||
expect(getMimeType('file.json')).toBe('application/json');
|
expect(getMimeType('file.json')).toBe('application/json');
|
||||||
});
|
});
|
||||||
@@ -97,7 +97,7 @@ describe('Protocol Handler Utils', () => {
|
|||||||
|
|
||||||
it('should handle case insensitive extensions', () => {
|
it('should handle case insensitive extensions', () => {
|
||||||
expect(getMimeType('FILE.HTML')).toBe('text/html');
|
expect(getMimeType('FILE.HTML')).toBe('text/html');
|
||||||
expect(getMimeType('FILE.JS')).toBe('application/javascript');
|
expect(getMimeType('FILE.JS')).toBe('text/javascript');
|
||||||
expect(getMimeType('FILE.CSS')).toBe('text/css');
|
expect(getMimeType('FILE.CSS')).toBe('text/css');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
59
pnpm-lock.yaml
generated
59
pnpm-lock.yaml
generated
@@ -31,7 +31,7 @@ importers:
|
|||||||
version: 5.0.10
|
version: 5.0.10
|
||||||
turbo:
|
turbo:
|
||||||
specifier: latest
|
specifier: latest
|
||||||
version: 2.5.5
|
version: 2.5.6
|
||||||
|
|
||||||
examples/appwrite:
|
examples/appwrite:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
@@ -240,6 +240,9 @@ importers:
|
|||||||
electron-is-dev:
|
electron-is-dev:
|
||||||
specifier: ^3.0.1
|
specifier: ^3.0.1
|
||||||
version: 3.0.1
|
version: 3.0.1
|
||||||
|
mrmime:
|
||||||
|
specifier: ^2.0.1
|
||||||
|
version: 2.0.1
|
||||||
rollup:
|
rollup:
|
||||||
specifier: ^4.45.1
|
specifier: ^4.45.1
|
||||||
version: 4.45.1
|
version: 4.45.1
|
||||||
@@ -3824,38 +3827,38 @@ packages:
|
|||||||
tslib@2.8.1:
|
tslib@2.8.1:
|
||||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||||
|
|
||||||
turbo-darwin-64@2.5.5:
|
turbo-darwin-64@2.5.6:
|
||||||
resolution: {integrity: sha512-RYnTz49u4F5tDD2SUwwtlynABNBAfbyT2uU/brJcyh5k6lDLyNfYKdKmqd3K2ls4AaiALWrFKVSBsiVwhdFNzQ==}
|
resolution: {integrity: sha512-3C1xEdo4aFwMJAPvtlPqz1Sw/+cddWIOmsalHFMrsqqydcptwBfu26WW2cDm3u93bUzMbBJ8k3zNKFqxJ9ei2A==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
turbo-darwin-arm64@2.5.5:
|
turbo-darwin-arm64@2.5.6:
|
||||||
resolution: {integrity: sha512-Tk+ZeSNdBobZiMw9aFypQt0DlLsWSFWu1ymqsAdJLuPoAH05qCfYtRxE1pJuYHcJB5pqI+/HOxtJoQ40726Btw==}
|
resolution: {integrity: sha512-LyiG+rD7JhMfYwLqB6k3LZQtYn8CQQUePbpA8mF/hMLPAekXdJo1g0bUPw8RZLwQXUIU/3BU7tXENvhSGz5DPA==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
turbo-linux-64@2.5.5:
|
turbo-linux-64@2.5.6:
|
||||||
resolution: {integrity: sha512-2/XvMGykD7VgsvWesZZYIIVXMlgBcQy+ZAryjugoTcvJv8TZzSU/B1nShcA7IAjZ0q7OsZ45uP2cOb8EgKT30w==}
|
resolution: {integrity: sha512-GOcUTT0xiT/pSnHL4YD6Yr3HreUhU8pUcGqcI2ksIF9b2/r/kRHwGFcsHgpG3+vtZF/kwsP0MV8FTlTObxsYIA==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
turbo-linux-arm64@2.5.5:
|
turbo-linux-arm64@2.5.6:
|
||||||
resolution: {integrity: sha512-DW+8CjCjybu0d7TFm9dovTTVg1VRnlkZ1rceO4zqsaLrit3DgHnN4to4uwyuf9s2V/BwS3IYcRy+HG9BL596Iw==}
|
resolution: {integrity: sha512-10Tm15bruJEA3m0V7iZcnQBpObGBcOgUcO+sY7/2vk1bweW34LMhkWi8svjV9iDF68+KJDThnYDlYE/bc7/zzQ==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
turbo-windows-64@2.5.5:
|
turbo-windows-64@2.5.6:
|
||||||
resolution: {integrity: sha512-q5p1BOy8ChtSZfULuF1BhFMYIx6bevXu4fJ+TE/hyNfyHJIfjl90Z6jWdqAlyaFLmn99X/uw+7d6T/Y/dr5JwQ==}
|
resolution: {integrity: sha512-FyRsVpgaj76It0ludwZsNN40ytHN+17E4PFJyeliBEbxrGTc5BexlXVpufB7XlAaoaZVxbS6KT8RofLfDRyEPg==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
turbo-windows-arm64@2.5.5:
|
turbo-windows-arm64@2.5.6:
|
||||||
resolution: {integrity: sha512-AXbF1KmpHUq3PKQwddMGoKMYhHsy5t1YBQO8HZ04HLMR0rWv9adYlQ8kaeQJTko1Ay1anOBFTqaxfVOOsu7+1Q==}
|
resolution: {integrity: sha512-j/tWu8cMeQ7HPpKri6jvKtyXg9K1gRyhdK4tKrrchH8GNHscPX/F71zax58yYtLRWTiK04zNzPcUJuoS0+v/+Q==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
turbo@2.5.5:
|
turbo@2.5.6:
|
||||||
resolution: {integrity: sha512-eZ7wI6KjtT1eBqCnh2JPXWNUAxtoxxfi6VdBdZFvil0ychCOTxbm7YLRBi1JSt7U3c+u3CLxpoPxLdvr/Npr3A==}
|
resolution: {integrity: sha512-gxToHmi9oTBNB05UjUsrWf0OyN5ZXtD0apOarC1KIx232Vp3WimRNy3810QzeNSgyD5rsaIDXlxlbnOzlouo+w==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
type-check@0.4.0:
|
type-check@0.4.0:
|
||||||
@@ -7993,32 +7996,32 @@ snapshots:
|
|||||||
|
|
||||||
tslib@2.8.1: {}
|
tslib@2.8.1: {}
|
||||||
|
|
||||||
turbo-darwin-64@2.5.5:
|
turbo-darwin-64@2.5.6:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
turbo-darwin-arm64@2.5.5:
|
turbo-darwin-arm64@2.5.6:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
turbo-linux-64@2.5.5:
|
turbo-linux-64@2.5.6:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
turbo-linux-arm64@2.5.5:
|
turbo-linux-arm64@2.5.6:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
turbo-windows-64@2.5.5:
|
turbo-windows-64@2.5.6:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
turbo-windows-arm64@2.5.5:
|
turbo-windows-arm64@2.5.6:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
turbo@2.5.5:
|
turbo@2.5.6:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
turbo-darwin-64: 2.5.5
|
turbo-darwin-64: 2.5.6
|
||||||
turbo-darwin-arm64: 2.5.5
|
turbo-darwin-arm64: 2.5.6
|
||||||
turbo-linux-64: 2.5.5
|
turbo-linux-64: 2.5.6
|
||||||
turbo-linux-arm64: 2.5.5
|
turbo-linux-arm64: 2.5.6
|
||||||
turbo-windows-64: 2.5.5
|
turbo-windows-64: 2.5.6
|
||||||
turbo-windows-arm64: 2.5.5
|
turbo-windows-arm64: 2.5.6
|
||||||
|
|
||||||
type-check@0.4.0:
|
type-check@0.4.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user