Skip to content

Commit

Permalink
fix(Post): use tag-joining method for e6/e9 that eslint doesnt hate
Browse files Browse the repository at this point in the history
  • Loading branch information
AtoraSuunva committed Aug 3, 2022
1 parent df502b6 commit e105a50
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/structures/Post.ts
Expand Up @@ -67,22 +67,19 @@ function parseImageUrl(url: string, data: any, booru: Booru): string | null {
* @returns {string[]} The tags as a string array, and not just a string or an object
*/
function getTags(data: any): string[] {
let tags = []
let tags: string[] = []

if (Array.isArray(data.tags)) {
tags = data.tags
} else if (data.tags && data.tags.general) {
tags = Object.values<string>(data.tags).reduce(
(acc: string[], v) => (acc = acc.concat(v)),
[],
) as string[]
tags = Object.values<string>(data.tags).flat()
} else if (typeof data.tags === 'string') {
tags = fromTagString(data.tags)
} else if (typeof data.tag_string === 'string') {
tags = fromTagString(data.tag_string)
}

return tags.filter((v: string) => v !== '')
return tags.filter((v) => v !== '')
}

/**
Expand Down

0 comments on commit e105a50

Please sign in to comment.