citation-js 0.7.11 → 0.7.13
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/build/citation.js +35 -23
- package/build/citation.min.js +1 -1
- package/package.json +8 -9
package/build/citation.js
CHANGED
|
@@ -2783,14 +2783,20 @@ function _interopRequireDefault(obj) {
|
|
|
2783
2783
|
"default": obj
|
|
2784
2784
|
};
|
|
2785
2785
|
}
|
|
2786
|
-
var
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2786
|
+
var isBrowser = typeof location !== 'undefined' && typeof navigator !== 'undefined';
|
|
2787
|
+
var _ref = typeof fetch === 'function' && isBrowser ? {
|
|
2788
|
+
fetch: fetch,
|
|
2789
|
+
Headers: Headers
|
|
2790
|
+
} : (0, _fetchPonyfill["default"])(),
|
|
2791
|
+
asyncFetch = _ref.fetch,
|
|
2792
|
+
asyncHeaders = _ref.Headers;
|
|
2793
|
+
var userAgent = "Citation.js/".concat(_package["default"].version);
|
|
2794
|
+
if (process && process.release && process.release.name === 'node' && process.version) {
|
|
2795
|
+
userAgent += " Node.js/".concat(process.version);
|
|
2796
|
+
}
|
|
2791
2797
|
function normaliseHeaders(headers) {
|
|
2792
2798
|
var result = {};
|
|
2793
|
-
var entries = headers instanceof
|
|
2799
|
+
var entries = headers instanceof asyncHeaders || headers instanceof _syncFetch["default"].Headers ? Array.from(headers) : Object.entries(headers);
|
|
2794
2800
|
var _iterator = _createForOfIteratorHelper(entries),
|
|
2795
2801
|
_step;
|
|
2796
2802
|
try {
|
|
@@ -2816,7 +2822,7 @@ function parseOpts() {
|
|
|
2816
2822
|
method: 'GET',
|
|
2817
2823
|
checkContentType: opts.checkContentType
|
|
2818
2824
|
};
|
|
2819
|
-
if (userAgent && !
|
|
2825
|
+
if (userAgent && !isBrowser) {
|
|
2820
2826
|
reqOpts.headers['user-agent'] = userAgent;
|
|
2821
2827
|
}
|
|
2822
2828
|
if (opts.body) {
|
|
@@ -2881,7 +2887,7 @@ function _fetchFileAsync() {
|
|
|
2881
2887
|
case 0:
|
|
2882
2888
|
reqOpts = parseOpts(opts);
|
|
2883
2889
|
_logger["default"].http('[core]', reqOpts.method, url, reqOpts);
|
|
2884
|
-
return _context.abrupt("return",
|
|
2890
|
+
return _context.abrupt("return", asyncFetch(url, reqOpts).then(function (response) {
|
|
2885
2891
|
return checkResponse(response, reqOpts);
|
|
2886
2892
|
}).then(function (response) {
|
|
2887
2893
|
return response.text();
|
|
@@ -3426,7 +3432,7 @@ Translator.CONVERT_TO_TARGET = Symbol('convert to target');
|
|
|
3426
3432
|
},{}],43:[function(require,module,exports){
|
|
3427
3433
|
module.exports={
|
|
3428
3434
|
"name": "@citation-js/core",
|
|
3429
|
-
"version": "0.7.
|
|
3435
|
+
"version": "0.7.13",
|
|
3430
3436
|
"description": "Convert different bibliographic metadata sources",
|
|
3431
3437
|
"keywords": [
|
|
3432
3438
|
"citation-js",
|
|
@@ -3466,7 +3472,7 @@ module.exports={
|
|
|
3466
3472
|
"fetch-ponyfill": "^7.1.0",
|
|
3467
3473
|
"sync-fetch": "^0.4.1"
|
|
3468
3474
|
},
|
|
3469
|
-
"gitHead": "
|
|
3475
|
+
"gitHead": "9259e28a219854228c394f278c4973ee911d2bef"
|
|
3470
3476
|
}
|
|
3471
3477
|
|
|
3472
3478
|
},{}],44:[function(require,module,exports){
|
|
@@ -4269,6 +4275,7 @@ var _default = exports["default"] = {
|
|
|
4269
4275
|
},
|
|
4270
4276
|
format: {
|
|
4271
4277
|
useIdAsLabel: false,
|
|
4278
|
+
checkLabel: true,
|
|
4272
4279
|
asciiOnly: true
|
|
4273
4280
|
},
|
|
4274
4281
|
biber: {
|
|
@@ -7268,6 +7275,20 @@ function _interopRequireDefault(obj) {
|
|
|
7268
7275
|
var stopWords = new Set(['the', 'a', 'an']);
|
|
7269
7276
|
var unsafeChars = /(?:<\/?.*?>|[\u0020-\u002F\u003A-\u0040\u005B-\u005E\u0060\u007B-\u007F])+/g;
|
|
7270
7277
|
var unicode = /[^\u0020-\u007F]+/g;
|
|
7278
|
+
function isLabelSafe(text) {
|
|
7279
|
+
return !_config["default"].format.checkLabel || !text.match(unsafeChars);
|
|
7280
|
+
}
|
|
7281
|
+
function formatLabelFromId(id) {
|
|
7282
|
+
if (id === null) {
|
|
7283
|
+
return 'null';
|
|
7284
|
+
} else if (id === undefined) {
|
|
7285
|
+
return 'undefined';
|
|
7286
|
+
} else if (_config["default"].format.checkLabel) {
|
|
7287
|
+
return id.toString().replace(unsafeChars, '');
|
|
7288
|
+
} else {
|
|
7289
|
+
return id.toString();
|
|
7290
|
+
}
|
|
7291
|
+
}
|
|
7271
7292
|
function firstWord(text) {
|
|
7272
7293
|
if (!text) {
|
|
7273
7294
|
return '';
|
|
@@ -7498,21 +7519,12 @@ var Converters = exports.Converters = {
|
|
|
7498
7519
|
return [label, label];
|
|
7499
7520
|
},
|
|
7500
7521
|
toSource: function toSource(id, label, author, issued, suffix, title) {
|
|
7501
|
-
|
|
7502
|
-
if (id === null) {
|
|
7503
|
-
safeId = 'null';
|
|
7504
|
-
} else if (id === undefined) {
|
|
7505
|
-
safeId = 'undefined';
|
|
7506
|
-
} else {
|
|
7507
|
-
safeId = id.toString().replace(unsafeChars, '');
|
|
7508
|
-
}
|
|
7509
|
-
if (_config["default"].format.useIdAsLabel) {
|
|
7510
|
-
return safeId;
|
|
7511
|
-
}
|
|
7512
|
-
if (label && !unsafeChars.test(label)) {
|
|
7522
|
+
if (label && isLabelSafe(label)) {
|
|
7513
7523
|
return label;
|
|
7524
|
+
} else if (_config["default"].format.useIdAsLabel) {
|
|
7525
|
+
return formatLabelFromId(id);
|
|
7514
7526
|
} else {
|
|
7515
|
-
return formatLabel(author, issued, suffix, title) ||
|
|
7527
|
+
return formatLabel(author, issued, suffix, title) || formatLabelFromId(id);
|
|
7516
7528
|
}
|
|
7517
7529
|
}
|
|
7518
7530
|
},
|