javascript-solid-server 0.0.203 → 0.0.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +17 -0
- package/package.json +2 -1
- package/src/mashlib/index.js +12 -6
- package/src/utils/url.js +10 -15
- package/test/url.test.js +22 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(gh issue *)",
|
|
5
|
+
"Bash(sort -t: -k3 -n)",
|
|
6
|
+
"Bash(sed -n '1,30p' docs/features/overview.md)",
|
|
7
|
+
"Bash(npm run *)",
|
|
8
|
+
"Bash(git add *)",
|
|
9
|
+
"Bash(git commit -q -m 'docs: add Account Management page with API endpoints \\(#23\\) *)",
|
|
10
|
+
"Bash(git push *)",
|
|
11
|
+
"Bash(gh pr create --title 'docs: Account Management page \\(change password, backup/export, delete\\) — closes #23' --body ' *)",
|
|
12
|
+
"Bash(gh pr *)",
|
|
13
|
+
"Bash(git checkout *)",
|
|
14
|
+
"Bash(git pull *)"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "javascript-solid-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.204",
|
|
4
4
|
"description": "A minimal, fast Solid server",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"fs-extra": "^11.2.0",
|
|
37
37
|
"jose": "^6.1.3",
|
|
38
38
|
"microfed": "^0.0.14",
|
|
39
|
+
"mime-types": "^2.1.35",
|
|
39
40
|
"n3": "^1.26.0",
|
|
40
41
|
"oidc-provider": "^9.6.0",
|
|
41
42
|
"sql.js": "^1.13.0",
|
package/src/mashlib/index.js
CHANGED
|
@@ -356,8 +356,12 @@ export function shouldServeMashlib(request, mashlibEnabled, contentType) {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
//
|
|
360
|
-
|
|
359
|
+
// Serve the mashlib shell only for content types that have a pane to
|
|
360
|
+
// render them. RDF + markdown + playlists, plus any single audio type
|
|
361
|
+
// (the audio pane). Do NOT add video/image types here until panes exist
|
|
362
|
+
// for them — wrapping them would show "No data found" instead of the
|
|
363
|
+
// browser's native inline render. See #533.
|
|
364
|
+
const viewableTypes = [
|
|
361
365
|
'text/turtle',
|
|
362
366
|
'application/ld+json',
|
|
363
367
|
'application/json',
|
|
@@ -365,13 +369,15 @@ export function shouldServeMashlib(request, mashlibEnabled, contentType) {
|
|
|
365
369
|
'application/n-triples',
|
|
366
370
|
'application/rdf+xml',
|
|
367
371
|
'text/markdown',
|
|
368
|
-
'
|
|
369
|
-
'application/vnd.apple.mpegurl',
|
|
370
|
-
'audio/x-scpls'
|
|
372
|
+
'application/vnd.apple.mpegurl'
|
|
371
373
|
];
|
|
372
374
|
|
|
373
375
|
const baseType = contentType.split(';')[0].trim().toLowerCase();
|
|
374
|
-
|
|
376
|
+
// Any audio/* type (mpeg, ogg, wave, x-flac, mpegurl playlists, ...) has a
|
|
377
|
+
// pane (audio or playlist), so match the whole family rather than enumerate
|
|
378
|
+
// the exact spellings the mime-types db happens to use.
|
|
379
|
+
if (baseType.startsWith('audio/')) return true;
|
|
380
|
+
return viewableTypes.includes(baseType);
|
|
375
381
|
}
|
|
376
382
|
|
|
377
383
|
/**
|
package/src/utils/url.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import * as mime from 'mime-types';
|
|
2
3
|
|
|
3
4
|
// Base directory for storing all pods
|
|
4
5
|
// Use a getter function to read env var at runtime (not import time)
|
|
@@ -218,28 +219,19 @@ function getPodNameFromPath(urlPath) {
|
|
|
218
219
|
*/
|
|
219
220
|
export function getContentType(filePath) {
|
|
220
221
|
const ext = path.extname(filePath).toLowerCase();
|
|
221
|
-
|
|
222
|
+
|
|
223
|
+
// Solid-specific overrides — types the `mime-types` db doesn't know, or
|
|
224
|
+
// where Solid semantics differ. Checked before falling back to mime-types
|
|
225
|
+
// (which covers the long tail: audio/video/fonts/archives/office/etc.).
|
|
226
|
+
const overrides = {
|
|
222
227
|
'.jsonld': 'application/ld+json',
|
|
223
|
-
'.json': 'application/json',
|
|
224
|
-
'.html': 'text/html',
|
|
225
|
-
'.txt': 'text/plain',
|
|
226
|
-
'.css': 'text/css',
|
|
227
|
-
'.js': 'application/javascript',
|
|
228
|
-
'.png': 'image/png',
|
|
229
|
-
'.jpg': 'image/jpeg',
|
|
230
|
-
'.jpeg': 'image/jpeg',
|
|
231
|
-
'.gif': 'image/gif',
|
|
232
|
-
'.svg': 'image/svg+xml',
|
|
233
|
-
'.pdf': 'application/pdf',
|
|
234
228
|
'.ttl': 'text/turtle',
|
|
235
229
|
'.n3': 'text/n3',
|
|
236
230
|
'.nt': 'application/n-triples',
|
|
237
231
|
'.rdf': 'application/rdf+xml',
|
|
238
232
|
'.nq': 'application/n-quads',
|
|
239
233
|
'.trig': 'application/trig',
|
|
240
|
-
'.md': 'text/markdown',
|
|
241
234
|
'.m3u': 'audio/mpegurl',
|
|
242
|
-
'.m3u8': 'application/vnd.apple.mpegurl',
|
|
243
235
|
'.pls': 'audio/x-scpls',
|
|
244
236
|
// Solid ACL/meta as extensions (e.g. publicTypeIndex.jsonld.acl)
|
|
245
237
|
'.acl': 'application/ld+json',
|
|
@@ -255,7 +247,10 @@ export function getContentType(filePath) {
|
|
|
255
247
|
const base = path.basename(filePath);
|
|
256
248
|
if (base === '.acl' || base === '.meta') return 'application/ld+json';
|
|
257
249
|
|
|
258
|
-
|
|
250
|
+
// Overrides first, then the comprehensive mime-types database (as CSS and
|
|
251
|
+
// NSS do), then octet-stream. This is what makes audio/video/etc. resolve
|
|
252
|
+
// to a real type instead of forcing a download. See #533.
|
|
253
|
+
return overrides[ext] || mime.lookup(filePath) || 'application/octet-stream';
|
|
259
254
|
}
|
|
260
255
|
|
|
261
256
|
/**
|
package/test/url.test.js
CHANGED
|
@@ -94,7 +94,28 @@ describe('getContentType', () => {
|
|
|
94
94
|
assert.strictEqual(getContentType('/x/card.ttl'), 'text/turtle');
|
|
95
95
|
});
|
|
96
96
|
it('falls back to application/octet-stream for unknown extensions', () => {
|
|
97
|
-
|
|
97
|
+
// .zzz is not in the mime-types db (unlike .xyz → chemical/x-xyz)
|
|
98
|
+
assert.strictEqual(getContentType('/x/file.zzz'), 'application/octet-stream');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('media types via mime-types db (#533)', () => {
|
|
103
|
+
it('maps .mp3 → audio/mpeg (was octet-stream → forced download)', () => {
|
|
104
|
+
assert.strictEqual(getContentType('/music/song.mp3'), 'audio/mpeg');
|
|
105
|
+
});
|
|
106
|
+
it('maps common audio extensions to audio/*', () => {
|
|
107
|
+
for (const f of ['a.ogg', 'a.wav', 'a.m4a', 'a.flac', 'a.opus', 'a.aac']) {
|
|
108
|
+
assert.ok(getContentType(f).startsWith('audio/'), f + ' should be audio/*, got ' + getContentType(f));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
it('maps video and other common types', () => {
|
|
112
|
+
assert.strictEqual(getContentType('v.mp4'), 'video/mp4');
|
|
113
|
+
assert.strictEqual(getContentType('d.pdf'), 'application/pdf');
|
|
114
|
+
});
|
|
115
|
+
it('keeps Solid overrides ahead of the mime-types db', () => {
|
|
116
|
+
assert.strictEqual(getContentType('card.ttl'), 'text/turtle');
|
|
117
|
+
assert.strictEqual(getContentType('x.jsonld'), 'application/ld+json');
|
|
118
|
+
assert.strictEqual(getContentType('p.m3u'), 'audio/mpegurl');
|
|
98
119
|
});
|
|
99
120
|
});
|
|
100
121
|
|