GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

src/util/mimeDictionary.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 34
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 21
mnd 2
bc 2
fnc 2
dl 0
loc 34
rs 10
bpm 1
cpm 2
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A mimeDictionary.js ➔ guessMimeType 0 13 4
1
import findKey from 'lodash/findKey'
2
3
const mimeTypes = {
4
    "text/csv": {
5
        "source": "iana",
6
        "compressible": true,
7
        "extensions": ["csv"]
8
    },
9
    "application/vnd.ms-excel": {
10
        "source": "iana",
11
        "compressible": false,
12
        "extensions": ["xls", "xlm", "xla", "xlc", "xlt", "xlw"]
13
    },
14
    "text/plain": {
15
        "source": "iana",
16
        "compressible": true,
17
        "extensions": ["txt", "text", "conf", "def", "list", "log", "in", "ini"]
18
    },
19
};
20
21
22
export default function guessMimeType(path) {
23
    if (!path || typeof path !== 'string') {
24
        return false
25
    }
26
27
    let extension = path.split(".").pop();
28
29
    if (!extension) {
30
        return false
31
    }
32
33
    return findKey(mimeTypes, obj => obj.extensions.includes(extension)) || false;
34
}
35