@dov118/eso-status
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -0,1 +1,7 @@ | ||
## [1.1.11](https://github.com/dov118/eso-status/compare/1.1.10...1.1.11) (03/05/2021) | ||
### Code Refactoring | ||
* Update **README.md** ([b34dc49](https://github.com/dov118/eso-status/commit/b34dc4994fa1922afce43527d44815fb21774352)) | ||
* Replace polynomial regular expression used on uncontrolled data ([ba88f25](https://github.com/dov118/eso-status/commit/ba88f258ee694d2d75eca2dfa3ffd59094819e0d)) | ||
## [1.1.10](https://github.com/dov118/eso-status/compare/1.1.9...1.1.10) (01/05/2021) | ||
@@ -2,0 +8,0 @@ |
101
lib/index.js
@@ -44,4 +44,10 @@ "use strict"; | ||
EsoStatus.getRawListContent = function (rawContent) { | ||
var _a, _b; | ||
return (_b = (_a = /<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->.*?<p> <\/p>/s.exec(rawContent)) === null || _a === void 0 ? void 0 : _a.join('')) !== null && _b !== void 0 ? _b : ''; | ||
var resultRemoveBefore = rawContent.split('<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->'); | ||
if (resultRemoveBefore.length >= 2) { | ||
var resultRemoveAfter = resultRemoveBefore[1].split('<p> </p>'); | ||
if (resultRemoveAfter.length >= 2) { | ||
return "<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->" + resultRemoveAfter[0] + "<p> </p>"; | ||
} | ||
} | ||
return ''; | ||
}; | ||
@@ -55,14 +61,10 @@ /** | ||
EsoStatus.getRawContentItemList = function (rawListContent) { | ||
var rawContentItemList = []; | ||
var regex = /.*?<hr \/>/gs; | ||
var m; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((m = regex.exec(rawListContent)) !== null) { | ||
m.forEach(function (match) { | ||
rawContentItemList.push({ | ||
raw: match, | ||
}); | ||
}); | ||
} | ||
return rawContentItemList; | ||
return rawListContent | ||
.split('<hr />') | ||
.filter(function (item) { return !item.includes(' '); }) | ||
.map(function (item) { | ||
return { | ||
raw: item + "<hr />" | ||
}; | ||
}); | ||
}; | ||
@@ -77,28 +79,53 @@ /** | ||
return rawContentItemList.map(function (item) { | ||
// @ts-ignore | ||
var lines = item.raw.split('<p>').map(function (line) { | ||
var lineClear = line.split('</p>'); | ||
return lineClear.length >= 2 ? lineClear[0] : ''; | ||
}).filter(function (line) { return line !== ''; }); | ||
item.information_lines = []; | ||
var regex = /<p>(.*?)<\/p>/gs; | ||
var m; | ||
var index = 0; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((m = regex.exec(item.raw)) !== null) { | ||
m.forEach(function (match) { | ||
var _a; | ||
if (!match.includes('<p>')) { | ||
if (index === 0) { | ||
item.date_line = { | ||
raw: match, | ||
}; | ||
} | ||
else { | ||
(_a = item.information_lines) === null || _a === void 0 ? void 0 : _a.push({ | ||
raw: match, | ||
}); | ||
} | ||
} | ||
}); | ||
index++; | ||
} | ||
lines.forEach(function (line, index) { | ||
var _a; | ||
if (index === 0) { | ||
item.date_line = { | ||
raw: line, | ||
}; | ||
} | ||
else { | ||
(_a = item.information_lines) === null || _a === void 0 ? void 0 : _a.push({ | ||
raw: line, | ||
}); | ||
} | ||
}); | ||
return item; | ||
}); | ||
/* | ||
return rawContentItemList.map( | ||
(item: InformationBlock): InformationBlock => { | ||
// @ts-ignore | ||
item.information_lines = []; | ||
const regex: RegExp = /<p>(.*?)<\/p>/gs; | ||
let m; | ||
let index: number = 0; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((m = regex.exec(item.raw)) !== null) { | ||
m.forEach((match: string): void => { | ||
if (!match.includes('<p>')) { | ||
if (index === 0) { | ||
item.date_line = { | ||
raw: match, | ||
}; | ||
} else { | ||
item.information_lines?.push({ | ||
raw: match, | ||
}); | ||
} | ||
} | ||
}); | ||
index++; | ||
} | ||
return item; | ||
}, | ||
); | ||
*/ | ||
}; | ||
@@ -105,0 +132,0 @@ /** |
{ | ||
"name": "@dov118/eso-status", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "Library used to get servers status of The elders scrolls Online game", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# ESO-STATUS | ||
Eso-status is a library for getting and formatting data can founded in https://help.elderscrollsonline.com/app/answers/detail/a_id/4320/~/service-alerts | ||
Eso-status is a library for getting and formatting data can founded in [https://help.elderscrollsonline.com/app/answers/detail/a_id/4320](https://help.elderscrollsonline.com/app/answers/detail/a_id/4320) | ||
@@ -10,6 +10,9 @@ ## Table of Contents | ||
### How to get it ? | ||
[![npm package](https://nodeico.herokuapp.com/@dov118/eso-status.svg)](https://nodei.co/npm/@dov118/eso-status/) | ||
[![NPM](https://nodei.co/npm/@dov118/eso-status.png?downloads=true&downloadRank=true)](https://nodei.co/npm/@dov118/eso-status) | ||
[![npm version](https://img.shields.io/npm/v/@dov118/eso-status.svg)](https://www.npmjs.com/package/@dov118/eso-status) | ||
[![Downloads](https://img.shields.io/npm/dm/@dov118/eso-status.svg)](https://www.npmjs.com/package/@dov118/eso-status) | ||
[![Dependency Status](https://status.david-dm.org/gh/dov118/eso-status.svg)](https://status.david-dm.org/gh/dov118/eso-status) | ||
[![devDependency Status](https://status.david-dm.org/gh/dov118/eso-status.svg?type=dev)](https://david-dm.org/dov118/eso-status#info=devDependencies) | ||
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/dov118/eso-status.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dov118/eso-status/context:javascript) | ||
@@ -16,0 +19,0 @@ ```shell |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31437
628
157