feature(client) view: unknown file type: method: GET -> HEAD: speed up

This commit is contained in:
coderaiser 2021-02-03 13:53:41 +02:00
parent 5e545c87b3
commit 60607184d4
3 changed files with 10 additions and 3 deletions

View file

@ -63,7 +63,9 @@ function isVideo(name) {
module.exports._detectType = detectType;
async function detectType(path) {
const {headers} = await fetch(path);
const {headers} = await fetch(path, {
method: 'HEAD',
});
for (const [name, value] of headers) {
if (name === 'content-type')

View file

@ -27,8 +27,13 @@ test('cloudcmd: client: view: types: detectType', async (t) => {
await _detectType('/hello');
global.fetch = originalFetch;
const expected = [
'/hello', {
method: 'HEAD',
}
];
t.calledWith(fetch, ['/hello']);
t.calledWith(fetch, expected);
t.end();
});

View file

@ -122,7 +122,7 @@
"putout": "^14.0.0",
"redzip": "^1.6.4",
"rendy": "^3.0.0",
"restafary": "^9.5.0",
"restafary": "^9.6.0",
"restbox": "^3.0.0",
"shortdate": "^2.0.0",
"simport": "^1.0.1",