parse-accept-language 2.0.0 → 2.1.0
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/README.md +7 -7
- package/lib/parse-accept-language.js +3 -3
- package/package.json +7 -6
- package/History.md +0 -24
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[![NPM version][npm-image]][npm-url]
|
|
2
|
-
[![Build Status][
|
|
3
|
-
[![Dependency Status][
|
|
2
|
+
[![Build Status][build-image]][build-url]
|
|
3
|
+
[![Dependency Status][deps-image]][deps-url]
|
|
4
4
|
|
|
5
5
|
# parse-accept-language
|
|
6
6
|
|
|
@@ -24,11 +24,11 @@ var pal = parseAcceptLanguage(req);
|
|
|
24
24
|
|
|
25
25
|
MIT © [Damian Krzeminski](https://pirxpilot.me)
|
|
26
26
|
|
|
27
|
-
[npm-image]: https://img.shields.io/npm/v/parse-accept-language
|
|
27
|
+
[npm-image]: https://img.shields.io/npm/v/parse-accept-language
|
|
28
28
|
[npm-url]: https://npmjs.org/package/parse-accept-language
|
|
29
29
|
|
|
30
|
-
[
|
|
31
|
-
[
|
|
30
|
+
[build-url]: https://github.com/pirxpilot/parse-accept-language/actions/workflows/check.yaml
|
|
31
|
+
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/parse-accept-language/check.yaml?branch=main
|
|
32
32
|
|
|
33
|
-
[
|
|
34
|
-
[
|
|
33
|
+
[deps-image]: https://img.shields.io/librariesio/release/npm/parse-accept-language
|
|
34
|
+
[deps-url]: https://libraries.io/npm/parse-accept-language
|
|
@@ -26,8 +26,8 @@ function parseTag(tag) {
|
|
|
26
26
|
return el;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function str2array(acceptLanguage) {
|
|
30
|
-
return
|
|
29
|
+
function str2array(acceptLanguage = '') {
|
|
30
|
+
return acceptLanguage.split(',')
|
|
31
31
|
.map(parseTag)
|
|
32
32
|
.filter(Boolean) // filter empty
|
|
33
33
|
.sort((a, b) => b.q - a.q);
|
|
@@ -38,7 +38,7 @@ function parse(req) {
|
|
|
38
38
|
if(req._parsedAcceptLanguage) {
|
|
39
39
|
return req._parsedAcceptLanguage;
|
|
40
40
|
}
|
|
41
|
-
const acceptLanguage = req.
|
|
41
|
+
const acceptLanguage = req.headers['accept-language'];
|
|
42
42
|
req._parsedAcceptLanguage = str2array(acceptLanguage);
|
|
43
43
|
req._parsedAcceptLanguage._raw = acceptLanguage;
|
|
44
44
|
return req._parsedAcceptLanguage;
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parse-accept-language",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Parse 'Accept-Language' header and cache the result in request.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
7
7
|
"email": "pirxpilot@furkot.com",
|
|
8
8
|
"url": "https://pirxpilot.me"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/pirxpilot/parse-accept-language.git"
|
|
13
|
+
},
|
|
11
14
|
"license": "MIT",
|
|
12
15
|
"keywords": [
|
|
13
16
|
"parse-accept-language",
|
|
@@ -18,9 +21,7 @@
|
|
|
18
21
|
],
|
|
19
22
|
"dependencies": {},
|
|
20
23
|
"devDependencies": {
|
|
21
|
-
"jshint": "~
|
|
22
|
-
"mocha": "~7",
|
|
23
|
-
"should": "~13"
|
|
24
|
+
"@pirxpilot/jshint": "~3"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"test": "make check"
|
|
@@ -29,4 +30,4 @@
|
|
|
29
30
|
"index.js",
|
|
30
31
|
"lib"
|
|
31
32
|
]
|
|
32
|
-
}
|
|
33
|
+
}
|
package/History.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
2.0.0 / 2020-03-29
|
|
3
|
-
==================
|
|
4
|
-
|
|
5
|
-
* update node version in Travis CJ
|
|
6
|
-
* update dependencies
|
|
7
|
-
* rewrite in ES6
|
|
8
|
-
* replace .npmignore with package.json
|
|
9
|
-
* add test for country variants
|
|
10
|
-
|
|
11
|
-
1.0.2 / 2017-02-20
|
|
12
|
-
==================
|
|
13
|
-
|
|
14
|
-
* transfer repo to pirxpilot
|
|
15
|
-
|
|
16
|
-
1.0.1 / 2015-08-01
|
|
17
|
-
==================
|
|
18
|
-
|
|
19
|
-
* convert parsed region to upper case
|
|
20
|
-
|
|
21
|
-
1.0.0 / 2015-05-08
|
|
22
|
-
==================
|
|
23
|
-
|
|
24
|
-
* initial implementation
|