@ginstone/nga-api
Version:
45 lines (44 loc) • 1.26 kB
JavaScript
;
// 解析回复的位置
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplyLocation = void 0;
const PAGE_PATTERN = /page=(\d+)/;
const FORUM_PATTERN = /_ff=(-*\d+)/;
const REPLY_PATTERN = /pid(\d+)Anchor/;
const REPLY_PATTERN_2 = /pid=(\d+)/;
const TOPIC_PATTERN = /tid=(\d+)/;
class ReplyLocation {
constructor(location) {
{
const matcher = REPLY_PATTERN.exec(location);
if (matcher) {
this.replyId = Number(matcher[1]);
}
}
{
const matcher = FORUM_PATTERN.exec(location);
if (matcher) {
this.forumId = Number(matcher[1]);
}
}
{
const matcher = REPLY_PATTERN_2.exec(location);
if (matcher) {
this.replyId = Number(matcher[1]);
}
}
{
const matcher = TOPIC_PATTERN.exec(location);
if (matcher) {
this.topicId = Number(matcher[1]);
}
}
{
const matcher = PAGE_PATTERN.exec(location);
if (matcher) {
this.page = Number(matcher[1]);
}
}
}
}
exports.ReplyLocation = ReplyLocation;