Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xpadev-net committed Mar 1, 2023
2 parents 3cf742b + 39fa903 commit 12a31d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xpadev-net/niconicomments",
"version": "0.2.44",
"version": "0.2.45",
"description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
"main": "dist/bundle.js",
"types": "dist/bundle.d.ts",
Expand Down
7 changes: 4 additions & 3 deletions src/inputParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ const convert2formattedComment = (
const fromXMLDocument = (data: XMLDocument): formattedComment[] => {
const data_: formattedComment[] = [],
userList: string[] = [];
let index = Array.from(data.documentElement.children).length;
for (const item of Array.from(data.documentElement.children)) {
if (item.nodeName !== "chat") continue;
const tmpParam: formattedComment = {
id: Number(item.getAttribute("no")),
id: Number(item.getAttribute("no")) || index++,
vpos: Number(item.getAttribute("vpos")),
content: item.innerHTML,
date: Number(item.getAttribute("date")),
date_usec: Number(item.getAttribute("date_usec")),
date: Number(item.getAttribute("date")) || 0,
date_usec: Number(item.getAttribute("date_usec")) || 0,
owner: !item.getAttribute("user_id"),
premium: item.getAttribute("premium") === "1",
mail: [],
Expand Down
8 changes: 2 additions & 6 deletions src/typeGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,8 @@ const typeGuard = {
index++
) {
const value = (i as XMLDocument).documentElement.children[index];
if (!value) continue;
if (
value.nodeName === "chat" &&
!typeAttributeVerify(value, ["no", "vpos", "date", "date_usec", "mail"])
)
return false;
if (!value || value.nodeName !== "chat") continue;
if (!typeAttributeVerify(value, ["vpos", "date"])) return false;
}
return true;
},
Expand Down

0 comments on commit 12a31d5

Please sign in to comment.