UNPKG

@ginstone/nga-api

Version:

26 lines (25 loc) 925 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SimpleUserInfo = void 0; const PREFIX_178 = "https://img.nga.178.com/avatars/"; class SimpleUserInfo { constructor(raw) { this.userId = raw.uid; this.username = raw.username; if (raw.avatar) { raw.avatar = raw.avatar.replace("http:", "https"); raw.avatar = decodeURI(raw.avatar); if (raw.avatar.startsWith(PREFIX_178)) { this.avatars = []; const split = raw.avatar.split("\|\.a"); const first = split[0]; this.avatars.push(first); const prefix = first.substring(0, first.lastIndexOf("/")); for (let i = 1; i < split.length; i++) { this.avatars.push(prefix + split[i]); } } } } } exports.SimpleUserInfo = SimpleUserInfo;