chore(deps-dev): bump eslint-plugin-unicorn from 66.0.0 to 68.0.0 (#22310)

* chore(deps-dev): bump eslint-plugin-unicorn from 66.0.0 to 68.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 66.0.0 to 68.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v66.0.0...v68.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-version: 68.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: fix no-useless-coercion

* style: fix prefer-boolean-return

* style: fix no-useless-logical-operand

* style: fix prefer-single-replace

* style: fix consistent-conditional-object-spread

* style: fix no-useless-else

* style: fix prefer-unicode-code-point-escapes

* style: fix operator-assignment

* style: fix prefer-continue

* style: fix prefer-math-constants

* style: fix prefer-hoisting-branch-code

* style: fix prefer-array-slice

* style: fix consistent-class-member-order

* style: fix no-return-array-push

* style: fix prefer-promise-with-resolvers

* style: fix no-array-concat-in-loop

* style: fix no-loop-iterable-mutation

* style: fix no-invalid-argument-count

* style: fix no-duplicate-if-branches

* style: fix prefer-else-if

* style: fix no-unreadable-for-of-expression

* style: fix logical-assignment-operators

* style: fix default-export-style

* style: revert false positve in prefer-type-literal-last in #22274

* style: fix arrow-body-style

* style: add v68 recommended preset

* style: refactor GraphQL queries to use template literals for better readability

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
dependabot[bot]
2026-06-20 23:11:27 +08:00
committed by GitHub
co-authored by Tony
parent 19f8fb08d8
commit 417ab04f06
810 changed files with 1628 additions and 1591 deletions
+57 -9
View File
@@ -151,10 +151,11 @@
// "unicorn-js/better-dom-traversing": "error", false positive on cheerio
"unicorn/catch-error-name": "error",
"unicorn-js/class-reference-in-static-methods": "error",
// "unicorn-js/comment-content": "error", re-evaluate when unicorn > 66.0.0
"unicorn/consistent-assert": "error",
// "unicorn-js/consistent-boolean-name": "error", // unopinionated
"unicorn-js/consistent-class-member-order": "error",
"unicorn-js/consistent-compound-words": "error",
"unicorn-js/consistent-conditional-object-spread": "error",
"unicorn/consistent-date-clone": "error",
"unicorn/consistent-empty-array-spread": "error",
"unicorn/consistent-existence-index-check": "error",
@@ -163,6 +164,7 @@
"unicorn-js/consistent-json-file-read": "error",
"unicorn-js/consistent-optional-chaining": "error",
"unicorn/consistent-template-literal-escape": "error",
"unicorn-js/default-export-style": "error",
"unicorn/empty-brace-spaces": "error",
"unicorn/error-message": "error",
"unicorn/escape-case": "error",
@@ -172,12 +174,16 @@
// "unicorn/filename-case": "error",
"unicorn/import-style": "error",
"unicorn-js/isolated-functions": "error",
"unicorn-js/logical-assignment-operators": "error",
"unicorn-js/max-nested-calls": "error",
// "unicorn-js/name-replacements": "error", // unopinionated, rebranded prevent-abbreviations
"unicorn/new-for-builtins": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-accessor-recursion": "error",
"unicorn-js/no-accidental-bitwise-operator": "error",
"unicorn/no-anonymous-default-export": "error",
// "unicorn/no-array-callback-reference": "error",
"unicorn-js/no-array-concat-in-loop": "error",
"unicorn/no-array-fill-with-reference-type": "error",
"unicorn/no-array-for-each": "error",
"unicorn-js/no-array-from-fill": "error",
@@ -185,17 +191,26 @@
// "unicorn/no-array-reduce": "error",
"unicorn/no-array-reverse": "error",
// "unicorn/no-array-sort": "error",
"unicorn-js/no-array-sort-for-min-max": "error",
"unicorn-js/no-array-splice": "error",
// "unicorn/no-await-expression-member": "error",
"unicorn/no-await-in-promise-methods": "error",
"unicorn-js/no-blob-to-file": "error",
// "unicorn-js/no-break-in-nested-loop": "error", unopinionated
"unicorn-js/no-boolean-sort-comparator": "error",
// "unicorn-js/no-break-in-nested-loop": "error", // unopinionated
// "unicorn-js/no-canvas-to-image": "error", // unused
"unicorn-js/no-chained-comparison": "error",
"unicorn-js/no-collection-bracket-access": "error",
"unicorn-js/no-computed-property-existence-check": "error",
"unicorn-js/no-confusing-array-splice": "error",
"unicorn-js/no-confusing-array-with": "error",
"unicorn/no-console-spaces": "error",
// "unicorn-js/no-declarations-before-early-exit": "error", re-evaluate when unicorn > 66.0.0
"unicorn-js/no-constant-zero-expression": "error",
// "unicorn-js/no-declarations-before-early-exit": "error", // unopinionated
"unicorn/no-document-cookie": "error",
"unicorn-js/no-double-comparison": "error",
"unicorn-js/no-duplicate-if-branches": "error",
"unicorn-js/no-duplicate-logical-operands": "error",
"unicorn-js/no-duplicate-loops": "error",
"unicorn-js/no-duplicate-set-values": "error",
// "unicorn/no-empty-file": "error",
@@ -203,18 +218,21 @@
"unicorn-js/no-exports-in-scripts": "error",
// "unicorn/no-for-loop": "error", // won't be implemented
"unicorn-js/no-global-object-property-assignment": "error",
// "unicorn/no-hex-escape": "error",
"unicorn/no-immediate-mutation": "error",
"unicorn-js/no-impossible-length-comparison": "error",
"unicorn-js/no-incorrect-query-selector": "error",
// "unicorn-js/no-incorrect-template-string-interpolation": "error", too many false positives
// "unicorn-js/no-incorrect-template-string-interpolation": "error", // unopinionated, too many false positives in v68
"unicorn/no-instanceof-builtins": "error",
"unicorn-js/no-invalid-argument-count": "error",
"unicorn-js/no-invalid-character-comparison": "error",
"unicorn/no-invalid-fetch-options": "error",
"unicorn/no-invalid-remove-event-listener": "error",
"unicorn-js/no-late-current-target-access": "error",
"unicorn/no-lonely-if": "error",
"unicorn-js/no-loop-iterable-mutation": "error",
"unicorn/no-magic-array-flat-depth": "error",
"unicorn-js/no-mismatched-map-key": "error",
"unicorn-js/no-misrefactored-assignment": "error",
// "unicorn/no-named-default": "error", -> use import/no-named-default
"unicorn-js/no-negated-array-predicate": "error",
"unicorn-js/no-negated-comparison": "error",
@@ -225,6 +243,8 @@
// "unicorn/no-nested-ternary": "error",
"unicorn/no-new-array": "error",
"unicorn/no-new-buffer": "error",
"unicorn-js/no-non-function-verb-prefix": "error",
"unicorn-js/no-nonstandard-builtin-properties": "error",
// "unicorn/no-null": "error",
// "unicorn/no-object-as-default-parameter": "error",
"unicorn-js/no-object-methods-with-collections": "error",
@@ -232,64 +252,81 @@
// "unicorn/no-process-exit": "error",
"unicorn-js/no-redundant-comparison": "error",
"unicorn-js/no-return-array-push": "error",
"unicorn-js/no-selector-as-dom-name": "error",
"unicorn/no-single-promise-in-promise-methods": "error",
"unicorn/no-static-only-class": "error",
"unicorn-js/no-subtraction-comparison": "error",
"unicorn/no-thenable": "error",
"unicorn/no-this-assignment": "error",
"unicorn-js/no-this-outside-of-class": "error",
// "unicorn-js/no-top-level-assignment-in-function": "error", // unopinionated
// "unicorn-js/no-top-level-side-effects": "error", // allows dayjs.extend()
"unicorn/no-typeof-undefined": "error",
"unicorn-js/no-uncalled-method": "error",
"unicorn-js/no-undeclared-class-members": "error",
"unicorn/no-unnecessary-array-flat-depth": "error",
"unicorn/no-unnecessary-array-splice-count": "error",
"unicorn/no-unnecessary-await": "error",
"unicorn-js/no-unnecessary-boolean-comparison": "error",
"unicorn-js/no-unnecessary-global-this": "error",
"unicorn-js/no-unnecessary-nested-ternary": "error",
"unicorn-js/no-unnecessary-polyfills": "error",
"unicorn/no-unnecessary-slice-end": "error",
"unicorn-js/no-unnecessary-splice": "error",
"unicorn/no-unreadable-array-destructuring": "error",
"unicorn-js/no-unreadable-for-of-expression": "error",
"unicorn/no-unreadable-iife": "error",
// "unicorn-js/no-unreadable-new-expression": "error", // allows new URL(x).href
"unicorn-js/no-unreadable-object-destructuring": "error",
"unicorn-js/no-unsafe-buffer-conversion": "error",
"unicorn-js/no-unsafe-property-key": "error",
"unicorn-js/no-unsafe-string-replacement": "error",
"unicorn-js/no-unused-array-method-return": "error",
"unicorn-js/no-useless-boolean-cast": "error",
"unicorn-js/no-useless-coercion": "error",
"unicorn/no-useless-collection-argument": "error",
"unicorn-js/no-useless-compound-assignment": "error",
"unicorn-js/no-useless-concat": "error",
"unicorn-js/no-useless-continue": "error",
"unicorn-js/no-useless-delete-check": "error",
"unicorn-js/no-useless-else": "error",
"unicorn/no-useless-error-capture-stack-trace": "error",
"unicorn/no-useless-fallback-in-spread": "error",
// "unicorn/no-useless-iterator-to-array": "error",
"unicorn/no-useless-length-check": "error",
"unicorn-js/no-useless-logical-operand": "error",
"unicorn-js/no-useless-override": "error",
"unicorn/no-useless-promise-resolve-reject": "error",
// "unicorn-js/no-useless-recursion": "error", unopinionated
"unicorn/no-useless-spread": "error",
// "unicorn/no-useless-switch-case": "error",
"unicorn-js/no-useless-template-literals": "error",
// "unicorn/no-useless-undefined": "error",
"unicorn-js/no-xor-as-exponentiation": "error",
"unicorn/no-zero-fractions": "error",
// "unicorn/number-literal-case": "error",
// "unicorn/numeric-separators-style": "error",
"unicorn-js/operator-assignment": "error",
"unicorn/prefer-add-event-listener": "error",
"unicorn-js/prefer-add-event-listener-options": "error",
"unicorn/prefer-array-find": "error",
"unicorn/prefer-array-flat": "error",
"unicorn/prefer-array-flat-map": "error",
"unicorn-js/prefer-array-from-async": "error",
"unicorn-js/prefer-array-from-map": "error",
"unicorn/prefer-array-index-of": "error",
"unicorn-js/prefer-array-iterable-methods": "error",
"unicorn-js/prefer-array-last-methods": "error",
"unicorn-js/prefer-array-slice": "error",
"unicorn/prefer-array-some": "error",
"unicorn/prefer-at": "error",
"unicorn-js/prefer-await": "error",
"unicorn/prefer-bigint-literals": "error",
"unicorn/prefer-blob-reading-methods": "error",
"unicorn-js/prefer-boolean-return": "error",
"unicorn/prefer-class-fields": "error",
"unicorn/prefer-classlist-toggle": "error",
// "unicorn/prefer-code-point": "error",
"unicorn-js/prefer-continue": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-default-parameters": "error",
"unicorn-js/prefer-direct-iteration": "error",
@@ -298,11 +335,15 @@
"unicorn/prefer-dom-node-remove": "error",
"unicorn/prefer-dom-node-text-content": "error",
"unicorn-js/prefer-early-return": "error",
"unicorn-js/prefer-else-if": "error",
"unicorn/prefer-event-target": "error",
"unicorn/prefer-export-from": "error",
"unicorn-js/prefer-flat-math-min-max": "error",
"unicorn-js/prefer-get-or-insert-computed": "error",
"unicorn-js/prefer-global-number-constants": "error",
// "unicorn/prefer-global-this": "error",
"unicorn-js/prefer-has-check": "error",
"unicorn-js/prefer-hoisting-branch-code": "error",
// "unicorn-js/prefer-https": "error",
"unicorn-js/prefer-identifier-import-export-specifiers": "error",
"unicorn/prefer-includes": "error",
@@ -313,10 +354,12 @@
"unicorn/prefer-keyboard-event-key": "error",
"unicorn-js/prefer-location-assign": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn-js/prefer-map-from-entries": "error",
"unicorn-js/prefer-math-abs": "error",
"unicorn-js/prefer-math-constants": "error",
"unicorn/prefer-math-min-max": "error",
"unicorn/prefer-math-trunc": "error",
// "unicorn-js/prefer-minimal-ternary": "error", re-evaluate when unicorn > 66.0.0
// "unicorn-js/prefer-minimal-ternary": "error", // unopinionated, fixes have less readability
"unicorn/prefer-modern-dom-apis": "error",
"unicorn/prefer-modern-math-apis": "error",
// "unicorn/prefer-module": "error",
@@ -333,6 +376,7 @@
"unicorn/prefer-optional-catch-binding": "error",
// "unicorn-js/prefer-path2d": "error", // unused
"unicorn-js/prefer-private-class-fields": "error",
"unicorn-js/prefer-promise-with-resolvers": "error",
"unicorn/prefer-prototype-methods": "error",
"unicorn/prefer-query-selector": "error",
"unicorn-js/prefer-queue-microtask": "error",
@@ -342,12 +386,13 @@
"unicorn-js/prefer-scoped-selector": "error",
"unicorn/prefer-set-has": "error",
"unicorn/prefer-set-size": "error",
"unicorn-js/prefer-short-arrow-method": "error",
"unicorn-js/prefer-short-arrow-method": "warn",
"unicorn-js/prefer-simple-condition-first": "error",
"unicorn-js/prefer-simple-sort-comparator": "error",
"unicorn-js/prefer-single-array-predicate": "error",
"unicorn/prefer-single-call": "error",
"unicorn-js/prefer-single-object-destructuring": "error",
"unicorn-js/prefer-single-replace": "error",
"unicorn-js/prefer-smaller-scope": "error",
"unicorn-js/prefer-split-limit": "error",
// "unicorn/prefer-spread": "error",
@@ -366,7 +411,11 @@
"unicorn/prefer-type-error": "error",
"unicorn-js/prefer-type-literal-last": "error",
// "unicorn-js/prefer-uint8array-base64": "error", re-evaluate when node > 25
"unicorn-js/prefer-unary-minus": "error",
"unicorn-js/prefer-unicode-code-point-escapes": "error",
"unicorn-js/prefer-url-can-parse": "error",
"unicorn-js/prefer-url-href": "error",
"unicorn-js/prefer-while-loop-condition": "error",
// "unicorn/prevent-abbreviations": "error",
"unicorn/relative-url-style": "error",
"unicorn/require-array-join-separator": "error",
@@ -600,7 +649,6 @@
"unicorn/no-await-expression-member": "off",
"unicorn/no-empty-file": "warn",
// "unicorn/no-for-loop": "off", // won't be implemented
"unicorn/no-hex-escape": "warn",
"unicorn/no-nested-ternary": "off",
"unicorn/no-null": "off",
"unicorn/no-object-as-default-parameter": "warn",
+17 -13
View File
@@ -147,20 +147,24 @@ export default eslintCompatPlugin({
// 查找 features 属性
for (const prop of routeObject.properties) {
if (prop.type === 'Property' && prop.key && prop.key.name === 'features') {
featuresProperty = prop;
// 在 features 中查找 nsfw 属性
if (prop.value && prop.value.type === 'ObjectExpression') {
for (const featureProp of prop.value.properties) {
if (featureProp.type === 'Property' && featureProp.key && featureProp.key.name === 'nsfw') {
nsfwProperty = featureProp;
break;
}
}
}
break;
if (!(prop.type === 'Property' && prop.key && prop.key.name === 'features')) {
continue;
}
featuresProperty = prop;
// 在 features 中查找 nsfw 属性
if (prop.value && prop.value.type === 'ObjectExpression') {
for (const featureProp of prop.value.properties) {
if (!(featureProp.type === 'Property' && featureProp.key && featureProp.key.name === 'nsfw')) {
continue;
}
nsfwProperty = featureProp;
break;
}
}
break;
}
// 检查是否需要添加或修复 nsfw 标志
+14 -12
View File
@@ -7,19 +7,21 @@ const categoryList: Record<string, typeof namespaces> = {};
for (const namespace in namespaces) {
for (const path in namespaces[namespace].routes) {
if (namespaces[namespace].routes[path].categories?.length) {
for (const category of namespaces[namespace].routes[path].categories!) {
if (!Object.hasOwn(categoryList, category)) {
categoryList[category] = {};
}
if (!Object.hasOwn(categoryList[category], namespace)) {
categoryList[category][namespace] = {
...namespaces[namespace],
routes: {},
};
}
categoryList[category][namespace].routes[path] = namespaces[namespace].routes[path];
if (!namespaces[namespace].routes[path].categories?.length) {
continue;
}
const categories = namespaces[namespace].routes[path].categories!;
for (const category of categories) {
if (!Object.hasOwn(categoryList, category)) {
categoryList[category] = {};
}
if (!Object.hasOwn(categoryList[category], namespace)) {
categoryList[category][namespace] = {
...namespaces[namespace],
routes: {},
};
}
categoryList[category][namespace].routes[path] = namespaces[namespace].routes[path];
}
}
}
+1 -3
View File
@@ -1,5 +1,3 @@
class CaptchaError extends Error {
export default class CaptchaError extends Error {
name = 'CaptchaError';
}
export default CaptchaError;
+1 -3
View File
@@ -1,5 +1,3 @@
class ConfigNotFoundError extends Error {
export default class ConfigNotFoundError extends Error {
name = 'ConfigNotFoundError';
}
export default ConfigNotFoundError;
+1 -3
View File
@@ -1,5 +1,3 @@
class InvalidParameterError extends Error {
export default class InvalidParameterError extends Error {
name = 'InvalidParameterError';
}
export default InvalidParameterError;
+1 -3
View File
@@ -1,5 +1,3 @@
class NotFoundError extends Error {
export default class NotFoundError extends Error {
name = 'NotFoundError';
}
export default NotFoundError;
+1 -3
View File
@@ -1,5 +1,3 @@
class RejectError extends Error {
export default class RejectError extends Error {
name = 'RejectError';
}
export default RejectError;
+1 -3
View File
@@ -1,5 +1,3 @@
class RequestInProgressError extends Error {
export default class RequestInProgressError extends Error {
name = 'RequestInProgressError';
}
export default RequestInProgressError;
+1 -1
View File
@@ -272,7 +272,7 @@ const testAntiHotlink = async (path, expectObj, query?: string | Record<string,
.map(([key, value]) => `${key}=${value}`)
.join('&');
}
path = path + (queryStr ? `?${queryStr}` : '');
path += (queryStr ? `?${queryStr}` : '');
const response = await app.request(path);
const parsed = await parser.parseString(await response.text());
+7 -7
View File
@@ -12,13 +12,13 @@ enum LogPrefix {
const colorStatus = (status: number) => {
const out: { [key: string]: string } = {
7: `\u001B[35m${status}\u001B[0m`,
5: `\u001B[31m${status}\u001B[0m`,
4: `\u001B[33m${status}\u001B[0m`,
3: `\u001B[36m${status}\u001B[0m`,
2: `\u001B[32m${status}\u001B[0m`,
1: `\u001B[32m${status}\u001B[0m`,
0: `\u001B[33m${status}\u001B[0m`,
7: `\u{1B}[35m${status}\u{1B}[0m`,
5: `\u{1B}[31m${status}\u{1B}[0m`,
4: `\u{1B}[33m${status}\u{1B}[0m`,
3: `\u{1B}[36m${status}\u{1B}[0m`,
2: `\u{1B}[32m${status}\u{1B}[0m`,
1: `\u{1B}[32m${status}\u{1B}[0m`,
0: `\u{1B}[33m${status}\u{1B}[0m`,
};
const calculateStatus = Math.trunc(status / 100);
+5 -4
View File
@@ -2,16 +2,17 @@ import { describe, expect, it, vi } from 'vitest';
class FakeRE2 {
static CASE_INSENSITIVE = 1;
static compile(pattern: string) {
return new FakeRE2(pattern);
}
private pattern: string;
constructor(pattern: string) {
this.pattern = pattern;
}
static compile(pattern: string) {
return new FakeRE2(pattern);
}
matcher(text: string) {
return {
find: () => text.includes(this.pattern),
+15 -13
View File
@@ -74,11 +74,11 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
// fix allowEmpty
data.item = data.item || [];
data.item ||= [];
// decode HTML entities
data.title && (data.title = entities.decodeXML(data.title + ''));
data.description && (data.description = entities.decodeXML(data.description + ''));
data.title &&= entities.decodeXML(data.title + '');
data.description &&= entities.decodeXML(data.description + '');
// sort items
if (ctx.req.query('sorted') !== 'false') {
@@ -86,7 +86,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
const handleItem = (item: DataItem) => {
item.title && (item.title = entities.decodeXML(item.title + ''));
item.title &&= entities.decodeXML(item.title + '');
// handle pubDate
if (item.pubDate) {
@@ -227,15 +227,15 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
if (ctx.req.query('filter_description')) {
const descriptionRegex = makeRegex(ctx.req.query('filter_description')!);
isFilter = isFilter && (descriptionRegex instanceof RE2JS ? descriptionRegex.matcher(description).find() : !!descriptionRegex.test(description));
isFilter &&= descriptionRegex instanceof RE2JS ? descriptionRegex.matcher(description).find() : !!descriptionRegex.test(description);
}
if (ctx.req.query('filter_author')) {
const authorRegex = makeRegex(ctx.req.query('filter_author')!);
isFilter = isFilter && (authorRegex instanceof RE2JS ? authorRegex.matcher(author).find() : !!authorRegex.test(author));
isFilter &&= authorRegex instanceof RE2JS ? authorRegex.matcher(author).find() : !!authorRegex.test(author);
}
if (ctx.req.query('filter_category')) {
const categoryRegex = makeRegex(ctx.req.query('filter_category')!);
isFilter = isFilter && category.some((c) => (categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
isFilter &&= category.some((c) => (categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
}
return isFilter;
@@ -256,15 +256,15 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
}
if (ctx.req.query('filterout') || ctx.req.query('filterout_description')) {
const descriptionRegex = makeRegex(ctx.req.query('filterout_description') || ctx.req.query('filterout')!);
isFilter = isFilter && (descriptionRegex instanceof RE2JS ? !descriptionRegex.matcher(description).find() : !descriptionRegex.test(description));
isFilter &&= descriptionRegex instanceof RE2JS ? !descriptionRegex.matcher(description).find() : !descriptionRegex.test(description);
}
if (ctx.req.query('filterout_author')) {
const authorRegex = makeRegex(ctx.req.query('filterout_author')!);
isFilter = isFilter && (authorRegex instanceof RE2JS ? !authorRegex.matcher(author).find() : !authorRegex.test(author));
isFilter &&= authorRegex instanceof RE2JS ? !authorRegex.matcher(author).find() : !authorRegex.test(author);
}
if (ctx.req.query('filterout_category')) {
const categoryRegex = makeRegex(ctx.req.query('filterout_category')!);
isFilter = isFilter && category.every((c) => !(categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
isFilter &&= category.every((c) => !(categoryRegex instanceof RE2JS ? categoryRegex.matcher(c).find() : c.match(categoryRegex)));
}
return isFilter;
@@ -406,10 +406,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
if (num.test(ctx.req.query('brief')!)) {
const brief: number = Number.parseInt(ctx.req.query('brief')!);
for (const item of data.item) {
if (item.description) {
const text = sanitizeHtml(item.description, { allowedTags: [], allowedAttributes: {} });
item.description = text.length > brief ? `<p>${text.slice(0, brief)}…</p>` : `<p>${text}</p>`;
if (!item.description) {
continue;
}
const text = sanitizeHtml(item.description, { allowedTags: [], allowedAttributes: {} });
item.description = text.length > brief ? `<p>${text.slice(0, brief)}…</p>` : `<p>${text}</p>`;
}
} else {
throw new Error('Invalid parameter brief. Please check the doc https://docs.rsshub.app/guide/parameters#shu-chu-jian-xun');
+5 -5
View File
@@ -36,8 +36,8 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
if (data) {
data.title = collapseWhitespace(data.title) || '';
data.description && (data.description = collapseWhitespace(data.description) || '');
data.author && (data.author = collapseWhitespace(data.author) || '');
data.description &&= collapseWhitespace(data.description) || '';
data.author &&= collapseWhitespace(data.author) || '';
if (data.item) {
for (const item of data.item) {
@@ -59,7 +59,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
// remove unicode control characters
// see #14940 #14943 #15262
// oxlint-disable-next-line no-control-regex
item.description = item.description.replaceAll(/[\u0000-\u0009\v\f\u000E-\u001F\u007F\u200B\uFFFF]/g, '');
item.description = item.description.replaceAll(/[\u{0000}-\u{0009}\v\f\u{000E}-\u{001F}\u{007F}\u{200B}\u{FFFF}]/gu, '');
}
if (typeof item.author === 'string') {
@@ -81,12 +81,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
if (outputType !== 'rss') {
try {
item.pubDate && (item.pubDate = convertDateToISO8601(item.pubDate) || '');
item.pubDate &&= convertDateToISO8601(item.pubDate) || '';
} catch {
item.pubDate = '';
}
try {
item.updated && (item.updated = convertDateToISO8601(item.updated) || '');
item.updated &&= convertDateToISO8601(item.updated) || '';
} catch {
item.updated = '';
}
+1 -1
View File
@@ -67,7 +67,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
item.pubDate = timezone(parseDate($$('.time').text()), +8);
item.pubDate = timezone(parseDate($$('.time').text()), 8);
item.category = $$('meta[name="keywords"]').prop('content').split(/,/);
item.content = {
html: description,
+1 -1
View File
@@ -55,7 +55,7 @@ async function handler(ctx) {
$('.pageLink, .alert, p[style="margin:15px;"]').remove();
item.description = $('.post-content').html();
item.pubDate = timezone(parseDate($('.panel-body > .text-center').text().replace('时间:', ''), 'YYYY-MM-DD HH:mm:ss'), +8);
item.pubDate = timezone(parseDate($('.panel-body > .text-center').text().replace('时间:', ''), 'YYYY-MM-DD HH:mm:ss'), 8);
return item;
})
+1 -1
View File
@@ -134,7 +134,7 @@ async function handler(ctx) {
title: item.title,
author: item.source,
link: item.skipURL || item.url || `${rootUrl}/dy/article/${item.docid}.html`,
pubDate: timezone(parseDate(item.ptime), +8),
pubDate: timezone(parseDate(item.ptime), 8),
videoId: item.skipType === 'video' ? item.stitle : '',
}));
+1 -1
View File
@@ -48,7 +48,7 @@ async function handler(ctx) {
let items = response.data.data.items.map((item) => ({
title: item.title,
author: item.source,
pubDate: timezone(parseDate(item.ptime), +8),
pubDate: timezone(parseDate(item.ptime), 8),
description: `<p>${item.digest}</p><img src="${item.imgsrc}">`,
link: item.url || `https://c.m.163.com/news/a/${item.docid}.html`,
}));
+1 -1
View File
@@ -56,7 +56,7 @@ async function handler(ctx) {
let apiUrl = getApiUrl();
order = time === 'a' ? order : `${order}_${time}`;
apiUrl = `${apiUrl}/search?search_query=${encodedKeyword}&o=${order}`;
apiUrl += `/search?search_query=${encodedKeyword}&o=${order}`;
const apiResult = await processApiItems(apiUrl);
let filteredItemsByCategory = apiResult.content;
// Filter items by category if not 'all'
+1 -1
View File
@@ -100,7 +100,7 @@ async function handler(ctx) {
item.author = content('.uname, .user-name').first().text();
item.description = content('.post-cont').first().html() || content('.thread-cont').html();
item.pubDate = timezone(parseDate(content('.cont-top-left meta').first().attr('content')), +8);
item.pubDate = timezone(parseDate(content('.cont-top-left meta').first().attr('content')), 8);
return item;
})
+2 -2
View File
@@ -34,7 +34,7 @@ export const handler = async (ctx) => {
return {
title: subjectEl.text(),
pubDate: timezone(parseDate(item.find('span.date').text()), +8),
pubDate: timezone(parseDate(item.find('span.date').text()), 8),
link: new URL(subjectEl.prop('href'), rootUrl).href,
category: [
item.find('a.text-secondary').text().replaceAll('[]', ''),
@@ -63,7 +63,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
item.pubDate = timezone(parseDate($$('span.date').text()), +8);
item.pubDate = timezone(parseDate($$('span.date').text()), 8);
item.category = $$('a.badge')
.toArray()
.map((c) => $$(c).text());
+1 -1
View File
@@ -143,7 +143,7 @@ async function handler(ctx) {
});
item.author = content('.fl.black').first().text();
item.pubDate = timezone(parseDate(content('span.fl.gray').first().attr('title')), +8);
item.pubDate = timezone(parseDate(content('span.fl.gray').first().attr('title')), 8);
const readTpc = content('#read_tpc').first();
const copyLink = content('#copytext')?.first()?.text();
+3 -3
View File
@@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const processedItem: DataItem = {
title,
pubDate: pubDate ? timezone(parseRelativeDate(pubDate), +8) : undefined,
pubDate: pubDate ? timezone(parseRelativeDate(pubDate), 8) : undefined,
link: linkUrl,
category: categories,
author: authors,
@@ -141,13 +141,13 @@ export const handler = async (ctx: Context): Promise<Data> => {
const processedItem: DataItem = {
title,
description,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
content: {
html: description,
text: description,
},
updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
+1 -1
View File
@@ -53,7 +53,7 @@ async function handler(ctx) {
const first_post = content('td[id^="postmessage_"]').first();
const dateobj = content('em[id^="authorposton"]').first();
item.description = first_post.html();
item.pubDate = timezone(parseDate(dateobj.find('span').attr('title'), 'YYYY-M-D HH:mm:ss'), +8);
item.pubDate = timezone(parseDate(dateobj.find('span').attr('title'), 'YYYY-M-D HH:mm:ss'), 8);
return item;
})
+1 -1
View File
@@ -56,7 +56,7 @@ const getProperty = (object, key) => {
let result = object;
const keys = key.split('.');
for (const k of keys) {
result = result && result[k];
result &&= result[k];
}
return result;
};
+1 -5
View File
@@ -35,11 +35,7 @@ const processCatalog = ({ data, board, viewOptions }: { data: CatalogApiReturn;
return false;
}
if (viewOptions.maxReplies !== undefined && replies > viewOptions.maxReplies) {
return false;
}
return true;
return !(viewOptions.maxReplies !== undefined && replies > viewOptions.maxReplies);
})
.map((thread) => ({
author: `${thread.name} ${thread.trip ?? thread.no}`,
+4 -4
View File
@@ -182,9 +182,9 @@ async function handler(ctx) {
const title = l.contents().first().text();
const link = l.next().prop('href') ?? l.nextUntil('a').next().prop('href');
item.enclosure_url = item.enclosure_url ?? link;
item.enclosure_type = item.enclosure_type ?? 'application/x-bittorrent';
item.enclosure_title = item.enclosure_title ?? title;
item.enclosure_url ??= link;
item.enclosure_type ??= 'application/x-bittorrent';
item.enclosure_title ??= title;
return {
title,
@@ -237,7 +237,7 @@ async function handler(ctx) {
info: $$('div.nex_drama_sums').html(),
links,
});
item.pubDate = timezone(parseDate(pubDate, 'YYYY-M-D HH:mm:ss'), +8);
item.pubDate = timezone(parseDate(pubDate, 'YYYY-M-D HH:mm:ss'), 8);
item.category = Object.values(mergedDetails)
.flatMap((c) => c.split(/\s/))
.filter(Boolean);
+1 -1
View File
@@ -46,7 +46,7 @@ async function handler() {
return {
title: keyword[1],
author: keyword[2],
pubDate: timezone(parseDate(keyword[3], 'YYYY-MM-DD'), +8),
pubDate: timezone(parseDate(keyword[3], 'YYYY-MM-DD'), 8),
link,
};
});
+1 -1
View File
@@ -53,7 +53,7 @@ async function getFullcontent(item, cookie = '') {
return {
title: item.title,
link: item.url,
pubDate: parseDate(item.pubdate, +8),
pubDate: parseDate(item.pubdate, 8),
description: fullContent || item.abstract, // Return item.abstract if fullContent is null
};
}
+1 -1
View File
@@ -52,7 +52,7 @@ async function handler(ctx) {
.map((item) => ({
title: item.infoTitle,
author: item.quoteFrom,
pubDate: timezone(parseDate(item.infoStartTime), +8),
pubDate: timezone(parseDate(item.infoStartTime), 8),
link: `${rootUrl}/${area}/n/w/info/${item.infoCentreId}`,
}));
+1 -1
View File
@@ -62,7 +62,7 @@ async function handler(ctx) {
.map((item) => ({
title: item.infoTitle,
author: item.quoteFrom,
pubDate: timezone(parseDate(item.infoStartTime), +8),
pubDate: timezone(parseDate(item.infoStartTime), 8),
link: `${rootUrl}/global/n/w/info/${item.infoCentreId}`,
}));
+1 -1
View File
@@ -79,7 +79,7 @@ const fetchItems = async (limit, currentUrl, tryGet) => {
item.author = details.find((detail) => detail.label === '作者').value;
item.category = [details.find((detail) => detail.label === '状态').value, details.find((detail) => detail.label === '类型').value.text].filter(Boolean);
item.guid = `56kog-${item.link.match(/\/(\d+)\.html$/)[1]}#${pubDate}`;
item.pubDate = timezone(parseDate(pubDate), +8);
item.pubDate = timezone(parseDate(pubDate), 8);
} catch {
// no-empty
}
+3 -2
View File
@@ -70,7 +70,8 @@ const parseObject = (reg: RegExp, str: string): Record<string, string> => {
const obj = {};
const match = reg.exec(str);
if (match) {
for (const line of match[0].matchAll(/(\w+):\s?["']?([\s\S]+?)["']?[\n,}]/g)) {
const matchedLines = match[0].matchAll(/(\w+):\s?["']?([\s\S]+?)["']?[\n,}]/g);
for (const line of matchedLines) {
obj[line[1]] = line[2];
}
}
@@ -91,7 +92,7 @@ const decrypt = (txt: string, articleid: string, chapterid: string, decryptionMa
}
return txt
.replaceAll(/\u2003|\n/g, '')
.replaceAll(/\u{2003}|\n/gu, '')
.split('<br><br>')
.flatMap((line, index, array) => {
const mapped = lineMap[index];
+1 -1
View File
@@ -67,7 +67,7 @@ async function handler(ctx) {
item.title = content('title').text().replace(' -6park.com', '');
item.author = detailResponse.data.match(/送交者:[^>]*>([^<]*)<\/a>/)[1].trim();
item.pubDate = timezone(parseDate(detailResponse.data.match(/于 (.*) 已读/)[1], 'YYYY-MM-DD h:m'), +8);
item.pubDate = timezone(parseDate(detailResponse.data.match(/于 (.*) 已读/)[1], 'YYYY-MM-DD h:m'), 8);
item.description = content('pre')
.html()
.replaceAll('<p></p>', '')
+1 -1
View File
@@ -80,7 +80,7 @@ async function handler(ctx) {
item.title = content('h2').text();
item.author = matches[1].trim();
item.pubDate = timezone(parseDate(matches[2], 'YYYY-MM-DD h:m'), +8);
item.pubDate = timezone(parseDate(matches[2], 'YYYY-MM-DD h:m'), 8);
item.description = content('#shownewsc').html().replaceAll('<p></p>', '');
} catch {
// no-empty
+1 -1
View File
@@ -42,7 +42,7 @@ export async function processItems(ctx, baseURL, exclude) {
list.map((item) => {
const link = $(item).find('a');
const href = link.attr('href');
const pubDate = timezone(parseDate($(item).find('span').text().replaceAll(/[[\]]/g, ''), 'MM-DD'), +8);
const pubDate = timezone(parseDate($(item).find('span').text().replaceAll(/[[\]]/g, ''), 'MM-DD'), 8);
const text = link.text();
if (href === undefined) {
+2 -2
View File
@@ -49,7 +49,7 @@ export const handler = async (ctx) => {
return {
title,
description,
pubDate: pubDate && /\d{4}(?:\.\d{2}){2}\s\d{2}:\d{2}/.test(pubDate) ? timezone(parseDate(pubDate, 'YYYY.MM.DD HH:mm'), +8) : undefined,
pubDate: pubDate && /\d{4}(?:\.\d{2}){2}\s\d{2}:\d{2}/.test(pubDate) ? timezone(parseDate(pubDate, 'YYYY.MM.DD HH:mm'), 8) : undefined,
link: href?.startsWith('//') ? `https:${href}` : href,
category: [
...new Set([
@@ -104,7 +104,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
item.pubDate = timezone(parseDate($$('p.push-time').text().split(/:/).pop()), +8);
item.pubDate = timezone(parseDate($$('p.push-time').text().split(/:/).pop()), 8);
item.author = $$('a.push-username').contents().first().text();
item.content = {
html: description,
+2 -2
View File
@@ -27,7 +27,7 @@ export const handler = async (ctx) => {
return {
title: item.find('a').text(),
pubDate: timezone(parseDate(item.find('span').text()), +8),
pubDate: timezone(parseDate(item.find('span').text()), 8),
link: item.find('a').prop('href'),
language,
};
@@ -44,7 +44,7 @@ export const handler = async (ctx) => {
item.title = $$('h2').text();
item.description = description;
item.pubDate = timezone(parseDate($$('div.time span').last().text()), +8);
item.pubDate = timezone(parseDate($$('div.time span').last().text()), 8);
item.author = $$('div.time span').first().text();
item.content = {
html: description,
+1 -1
View File
@@ -145,7 +145,7 @@ async function handler(ctx) {
item.category = content('div.fl_dh a, div.site a')
.toArray()
.map((c) => content(c).text().trim());
item.pubDate = timezone(parseDate(pubDate, ['YYYY-MM-DD HH:mm', 'YYYY-M-D HH:mm']), +8);
item.pubDate = timezone(parseDate(pubDate, ['YYYY-MM-DD HH:mm', 'YYYY-M-D HH:mm']), 8);
return item;
})
+2 -2
View File
@@ -41,10 +41,10 @@ async function handler(ctx) {
}
if (ctx.req.param('tag')) {
link = `${link}/guides/${ctx.req.param('tag')}/feed/`;
link += `/guides/${ctx.req.param('tag')}/feed/`;
title = `${ctx.req.param('tag')} | ${title}`;
} else {
link = `${link}/feed/`;
link += '/feed/';
}
const feed = await parser.parseURL(link);
+2 -2
View File
@@ -43,7 +43,7 @@ export const handler = async (ctx) => {
]
: undefined,
}),
pubDate: timezone(parseDate(item.find('div.a9-rich-card-list_infos').text()), +8),
pubDate: timezone(parseDate(item.find('div.a9-rich-card-list_infos').text()), 8),
language,
};
});
@@ -95,7 +95,7 @@ export const handler = async (ctx) => {
.match(/发表于 (\d+-\d+-\d+ \d+:\d+)/)?.[1] ?? $$('span.c-article-main_content-intro-item').first().text(),
['YYYY-M-D HH:mm', 'YYYY-MM-DD HH:mm']
),
+8
8
);
item.language = language;
+1 -1
View File
@@ -56,7 +56,7 @@ async function handler(ctx) {
const $ = load(currentResponse);
documentId = documentId ?? $('div[data-uri^="coremedia://collection/"]').first().prop('data-uri').split(/\//).pop();
documentId ??= $('div[data-uri^="coremedia://collection/"]').first().prop('data-uri').split(/\//).pop();
const response = await ofetch(apiUrl, {
query: {
+1 -1
View File
@@ -44,7 +44,7 @@ async function handler(ctx) {
return {
title: item.prop('title'),
link: new URL(item.prop('href'), rootUrl).href,
pubDate: timezone(parseDate(item.find('span[title]').prop('title')), +8),
pubDate: timezone(parseDate(item.find('span[title]').prop('title')), 8),
};
});
+2 -2
View File
@@ -81,14 +81,14 @@ export const handler = async (ctx: Context): Promise<Data> => {
const processedItem: DataItem = {
title,
description,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
+2 -2
View File
@@ -81,14 +81,14 @@ export const handler = async (ctx: Context): Promise<Data> => {
const processedItem: DataItem = {
title,
description,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
html: description,
text: description,
},
updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
+1 -1
View File
@@ -72,7 +72,7 @@ export const handler = async (ctx) => {
item.title = title;
item.description = description;
item.pubDate = timezone(parseDate($$('meta[name="publishdate"]').prop('content')), +8);
item.pubDate = timezone(parseDate($$('meta[name="publishdate"]').prop('content')), 8);
item.author = $$('meta[name="author"]').prop('content') || $$('meta[name="source"]').prop('content');
item.content = {
html: description,
+1 -1
View File
@@ -54,7 +54,7 @@ async function handler() {
return {
title: item.find('a').attr('title'),
link,
pubDate: timezone(parseDate(date), +8),
pubDate: timezone(parseDate(date), 8),
};
});
+1 -1
View File
@@ -22,7 +22,7 @@ export const handler = async (ctx) => {
data: { results: apiTagProcs },
} = await ofetch(apiTagProcUrl, {
query: {
...(id ? { tag: id } : {}),
...(id && { tag: id }),
page: 1,
pagesize: 20,
f: filter,
+1 -1
View File
@@ -91,7 +91,7 @@ const processItems = (items: any[]): any[] =>
return {
title,
description,
pubDate: timezone(parseDate(item.addtime), +8),
pubDate: timezone(parseDate(item.addtime), 8),
link: new URL(`tool/${item.zurl}`, rootUrl).href,
category: [...new Set([...strToArray(item.categories), ...strToArray(item.tags), item.catname, item.procattrname, item.procformname, item.proctypename])].filter(Boolean),
guid,
+1
View File
@@ -61,4 +61,5 @@ const handler = async (ctx) => {
allowEmpty: true,
};
};
// TODO: missing route export
export default handler;
+1 -3
View File
@@ -37,9 +37,7 @@ async function handler(ctx) {
if (status === 'best') {
title = titleBest;
table = `<table border="1 solid black">${tableBest}</table>`;
}
if (status === 'worsest') {
} else if (status === 'worsest') {
title = titleWorst;
table = `<table border="1 solid black">${tableWorst}</table>`;
}
+1 -1
View File
@@ -50,7 +50,7 @@ async function handler(ctx) {
title: a.text(),
link: new URL(a.prop('href'), rootUrl).href,
author: a.text().split(':', 1)[0],
pubDate: timezone(parseDate(item.find('span').text()), +8),
pubDate: timezone(parseDate(item.find('span').text()), 8),
};
});
+1 -1
View File
@@ -28,7 +28,7 @@ const ProcessFeed = (limit, tryGet, items) =>
.find('u')
.toArray()
.map((c) => content(c).text());
item.pubDate = timezone(parseDate(content('div.info').text().split('时间:').pop()), +8);
item.pubDate = timezone(parseDate(content('div.info').text().split('时间:').pop()), 8);
item.upvotes = content('span.like-num').text() ? Number(content('span.like-num').text()) : 0;
item.comments = commentMatches ? Number(commentMatches[1]) : 0;
+1 -1
View File
@@ -53,7 +53,7 @@ async function handler(ctx) {
title: a.text(),
link: new URL(a.prop('href'), rootUrl).href,
author: a.text().split(':', 1)[0],
pubDate: timezone(parseDate(item.find('span').text()), +8),
pubDate: timezone(parseDate(item.find('span').text()), 8),
};
});
+1 -1
View File
@@ -134,7 +134,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
...item,
title,
description,
pubDate: timezone(parseDate($$('div.newstag_l').text().split(/\s/, 1)[0]), +8),
pubDate: timezone(parseDate($$('div.newstag_l').text().split(/\s/, 1)[0]), 8),
content: {
html: description,
text: $$('div#Content').html() ?? '',
+1 -1
View File
@@ -52,7 +52,7 @@ async function handler(ctx) {
let items = response.data.data.slice(0, limit).map((item) => ({
title: item.articleCode,
author: item.author,
pubDate: timezone(parseDate(item.gmtCreated), +8),
pubDate: timezone(parseDate(item.gmtCreated), 8),
link: `${rootUrl}/ch/information/informationdetails?articleCode=${item.articleCode}`,
}));
+1 -1
View File
@@ -55,7 +55,7 @@ async function handler(ctx) {
const title = element.find('a').text().trim();
const link = 'https://help.aliyun.com' + element.find('a').attr('href').trim();
const date = element.find('.y-right').text();
const pubDate = timezone(parseDate(date), +8);
const pubDate = timezone(parseDate(date), 8);
return {
title,
description: '',
+2 -2
View File
@@ -47,7 +47,7 @@ async function handler(ctx) {
const linkText = $(link).text();
title = title ? `${title} - ${linkText}` : linkText;
}
title = title || (category && topic ? `${category} - ${topic}` : category) || '首页';
title ||= (category && topic ? `${category} - ${topic}` : category) || '首页';
let links = [
// list page: http://rail.ally.net.cn/html/lujuzixun/
$('.left .hynewsO h2 a').toArray(),
@@ -106,7 +106,7 @@ async function handler(ctx) {
let innerHtml;
if (child.name === 'div') {
innerHtml = $child.html();
innerHtml = innerHtml && innerHtml.trim();
innerHtml &&= innerHtml.trim();
description += !innerHtml || innerHtml === '&nbsp;' ? (description ? '<br>' : '') : innerHtml;
} else {
// bare text node or something else
+1 -1
View File
@@ -48,7 +48,7 @@ async function handler(ctx) {
return content('#js-article').html();
})
: item.desc,
pubDate: timezone(parseDate(item.date), +8),
pubDate: timezone(parseDate(item.date), 8),
link: art_url,
author: item.author.nickname,
};
+1
View File
@@ -34,4 +34,5 @@ const handler = async () => {
};
};
// TODO: missing route export
export default handler;
+1 -1
View File
@@ -19,7 +19,7 @@ async function getArticles() {
return json.props.pageProps.list.map((item) => ({
title: item.title,
link: 'https://www.apiseven.com' + item.slug,
pubDate: timezone(parseDate(item.published_at), +8),
pubDate: timezone(parseDate(item.published_at), 8),
category: item.tags,
}));
}
+1 -1
View File
@@ -98,7 +98,7 @@ async function handler(ctx?: Context): Promise<Data> {
return {
title: $('title').text(),
link: currentUrl.toString(),
link: currentUrl,
allowEmpty: true,
item: items,
};
+1 -1
View File
@@ -85,7 +85,7 @@ export const route: Route = {
image: each.mainCoverUrl,
author: each.name,
link: `https://asmr-200.com/work/${each.source_id}`,
pubDate: timezone(parseDate(each.release, 'YYYY-MM-DD'), +8),
pubDate: timezone(parseDate(each.release, 'YYYY-MM-DD'), 8),
category,
description: render(each, `https://asmr-200.com/work/${each.source_id}`),
};
+1 -1
View File
@@ -46,7 +46,7 @@ async function handler(ctx) {
title: item.find('.panel-title').text(),
description: item.find('.panel-body').html(),
link: `${rootUrl}${item.find('.panel-title a').attr('href')}`,
pubDate: timezone(parseDate(item.find('.timeago').attr('datetime')), +9),
pubDate: timezone(parseDate(item.find('.timeago').attr('datetime')), 9),
};
});
+1 -1
View File
@@ -53,7 +53,7 @@ async function handler(ctx) {
return {
title: title.replace(/●/, '').split(/(\d+/, 1)[0],
link: new URL(item.parent().prop('href'), rootUrl).href,
pubDate: timezone(parseDate(pubDate, 'YYYY/M/D H:mm:ss'), +8),
pubDate: timezone(parseDate(pubDate, 'YYYY/M/D H:mm:ss'), 8),
};
});
+1 -1
View File
@@ -52,7 +52,7 @@ async function handler(ctx) {
link: a.attr('href'),
description: item.find('.coverdiv').html(),
author: item.find('.author').text().trim(),
pubDate: timezone(parseDate(item.find('time').attr('datetime')), +8),
pubDate: timezone(parseDate(item.find('time').attr('datetime')), 8),
category: item
.find('.label')
.toArray()
+1 -1
View File
@@ -72,7 +72,7 @@ async function handler(ctx) {
<p>作者:{author_name}</p>
</>
),
pubDate: timezone(parseDate(time, ['HH:mm', 'M-D', 'YYYY-MM'], true), +8),
pubDate: timezone(parseDate(time, ['HH:mm', 'M-D', 'YYYY-MM'], true), 8),
link: `https://tieba.baidu.com/p/${id}`,
};
});
+1 -1
View File
@@ -98,7 +98,7 @@ async function handler(ctx) {
{from}
</>
),
pubDate: timezone(parseDate(time, 'YYYY-MM-DD hh:mm'), +8),
pubDate: timezone(parseDate(time, 'YYYY-MM-DD hh:mm'), 8),
link: `https://tieba.baidu.com/p/${id}?pid=${content.post_id}#${content.post_id}`,
};
}),
+1 -1
View File
@@ -88,7 +88,7 @@ async function handler(ctx) {
</>
),
author,
pubDate: timezone(parseDate(time, 'YYYY-MM-DD HH:mm'), +8),
pubDate: timezone(parseDate(time, 'YYYY-MM-DD HH:mm'), 8),
link,
};
}),
+1 -1
View File
@@ -45,7 +45,7 @@ async function handler(ctx) {
imgurl = item.find('ul.n_media.clearfix img').attr('original');
return {
title: item.find('div.thread_name a').attr('title'),
pubDate: timezone(parseDate(item.parent().find('div .n_post_time').text(), ['YYYY-MM-DD', 'HH:mm']), +8),
pubDate: timezone(parseDate(item.parent().find('div .n_post_time').text(), ['YYYY-MM-DD', 'HH:mm']), 8),
description: `${item.find('div.n_txt').text()}<br><img src="${imgurl}">`,
link: item.find('div.thread_name a').attr('href'),
};
+1 -2
View File
@@ -1,7 +1,7 @@
import { config } from '@/config';
import got from '@/utils/got';
const getData = (tryGet) => {
export const getData = (tryGet) => {
const bgmCalendarUrl = 'https://api.bgm.tv/calendar';
const bgmDataUrl = 'https://cdn.jsdelivr.net/npm/bangumi-data/dist/data.json';
@@ -35,4 +35,3 @@ const getData = (tryGet) => {
)
);
};
export default getData;
+1 -1
View File
@@ -3,7 +3,7 @@ import { renderToString } from 'hono/jsx/dom/server';
import type { Route } from '@/types';
import cache from '@/utils/cache';
import getData from './_base';
import { getData } from './_base';
export const route: Route = {
path: '/calendar/today',
+2 -2
View File
@@ -63,7 +63,7 @@ async function handler(ctx) {
title,
description: $('.postTopic .topic_content').html(),
author: $('.postTopic .inner strong a').first().text(),
pubDate: timezone(parseDate($('.postTopic .re_info small').text().trim().slice(5)), +8),
pubDate: timezone(parseDate($('.postTopic .re_info small').text().trim().slice(5)), 8),
link,
};
@@ -74,7 +74,7 @@ async function handler(ctx) {
...finalLatestReplies.map((c) => ({
title: `${c.author} 回复了小组话题《${title}》`,
description: c.content,
pubDate: timezone(parseDate(c.date), +8),
pubDate: timezone(parseDate(c.date), 8),
author: c.author,
link: `${link}#${c.id}`,
})),
+1 -2
View File
@@ -3,7 +3,7 @@ import { load } from 'cheerio';
import ofetch from '@/utils/ofetch';
import { parseDate, parseRelativeDate } from '@/utils/parse-date';
const getComments = async (subjectID, minLength) => {
export const getComments = async (subjectID, minLength) => {
// bangumi.tv未提供获取“吐槽(comments)”的API,因此仍需要通过抓取网页来获取
const link = `https://bgm.tv/subject/${subjectID}/comments`;
const html = await ofetch(link);
@@ -46,4 +46,3 @@ const getComments = async (subjectID, minLength) => {
})),
};
};
export default getComments;
+1 -2
View File
@@ -6,7 +6,7 @@ import { parseDate } from '@/utils/parse-date';
import { getLocalName } from './utils';
const getEps = async (subjectID, showOriginalName) => {
export const getEps = async (subjectID, showOriginalName) => {
const url = `https://api.bgm.tv/subject/${subjectID}?responseGroup=large`;
const epsInfo = await ofetch(url);
const activeEps = epsInfo.eps.filter((e) => e.status === 'Air');
@@ -28,4 +28,3 @@ const getEps = async (subjectID, showOriginalName) => {
})),
};
};
export default getEps;
+3 -3
View File
@@ -2,9 +2,9 @@ import InvalidParameterError from '@/errors/types/invalid-parameter';
import type { Route } from '@/types';
import { queryToBoolean } from '@/utils/readable-social';
import getComments from './comments';
import getEps from './ep';
import getFromAPI from './offcial-subject-api';
import { getComments } from './comments';
import { getEps } from './ep';
import { getFromAPI } from './offcial-subject-api';
export const route: Route = {
path: '/subject/:id/:type?/:showOriginalName?',
@@ -3,7 +3,7 @@ import { parseDate } from '@/utils/parse-date';
import { getLocalName } from './utils';
const getFromAPI = (type) => {
export const getFromAPI = (type) => {
const mapping = {
blog: {
en: 'reviews',
@@ -32,4 +32,3 @@ const getFromAPI = (type) => {
};
};
};
export default getFromAPI;
+2 -2
View File
@@ -99,7 +99,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
const processedItem: DataItem = {
title,
description,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), 8) : item.pubDate,
category: categories,
author: authors,
content: {
@@ -108,7 +108,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
},
image,
banner: image,
updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
updated: upDatedStr ? timezone(parseDate(upDatedStr), 8) : item.updated,
language,
};
+2 -4
View File
@@ -3,7 +3,7 @@ import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
async function loadArticle(link) {
export const loadArticle = async (link) => {
const resp = await got(link);
const article = load(resp.body);
@@ -47,6 +47,4 @@ async function loadArticle(link) {
pubDate,
link,
};
}
export default loadArticle;
};
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import loadArticle from './article';
import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import loadArticle from './article';
import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import loadArticle from './article';
import { loadArticle } from './article';
import { SUB_NAME_PREFIX, SUB_URL } from './const';
export const route: Route = {
+2 -2
View File
@@ -68,7 +68,7 @@ async function handler(ctx) {
const content = load(detailResponse.data);
item.description = content('.cont_main').html();
item.pubDate = timezone(parseDate(content('.timeTag').text()), +8);
item.pubDate = timezone(parseDate(content('.timeTag').text()), 8);
return item;
})
@@ -89,7 +89,7 @@ async function handler(ctx) {
title,
description,
link: currentUrl,
pubDate: timezone(parseDate(`${item.parent().find('dt').text()} ${item.text()}`), +8),
pubDate: timezone(parseDate(`${item.parent().find('dt').text()} ${item.text()}`), 8),
};
});
+1 -1
View File
@@ -66,7 +66,7 @@ async function handler(ctx) {
item.title = content('meta[name="ArticleTitle"]').attr('content');
item.author = content('meta[name="contentSource"]').attr('content');
item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), +8);
item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), 8);
item.category = [content('meta[name="ColumnName"]').attr('content')];
item.description = content('.arccont').html();
+2 -1
View File
@@ -50,7 +50,8 @@ type Block = {
const applyAttributes = (content: JSX.Element | string, attributes?: BlockAttribute[]): JSX.Element | string => {
let result: JSX.Element | string = content;
for (const attribute of attributes ?? []) {
const attributeList = attributes ?? [];
for (const attribute of attributeList) {
switch (attribute) {
case 'bold':
result = <strong>{result}</strong>;
+1 -1
View File
@@ -197,7 +197,7 @@ async function handler(ctx) {
</>
);
item.pubDate = timezone(parseDate(content('.bg-purple-lt').text().replace('更新时间:', '')), +8);
item.pubDate = timezone(parseDate(content('.bg-purple-lt').text().replace('更新时间:', '')), 8);
item.guid = `${item.link}#${content('.card h1').text()}`;
item.enclosure_url = torrents.html() ? `${rootUrl}${torrents.find('a').first().attr('href')}` : downloadResponse.data.pop().url;
+1 -1
View File
@@ -164,7 +164,7 @@ async function handler(ctx) {
item.description = renderDescription(project.description, project.allModules);
item.category = [...new Set([...(item.category || []), ...(project.tags?.map((tag) => tag.title.toLowerCase()) || [])])];
item.pubDate = item.pubDate || (project.publishedOn ? parseDate(project.publishedOn, 'X') : undefined);
item.pubDate ||= project.publishedOn ? parseDate(project.publishedOn, 'X') : undefined;
return item;
})
+1 -1
View File
@@ -128,7 +128,7 @@ async function handler(ctx) {
.text()
.replace(/发布时间:/, '') ?? content('span.public_time').text()
),
+8
8
);
return item;
+5 -5
View File
@@ -123,7 +123,9 @@ const getWbiVerifyString = () => {
const array = JSON.parse(jsResponse.match(/\[(?:\d+,){63}\d+\]/));
const o = [];
for (const t of array) {
r.charAt(t) && o.push(r.charAt(t));
if (r.charAt(t)) {
o.push(r.charAt(t));
}
}
return o.join('').slice(0, 32);
});
@@ -365,13 +367,11 @@ const getArticleDataFromCvid = async (cvid, uid) => {
description += `<p>${text.word.words}</p>`;
}
}
}
if (element.para_type === 2) {
} else if (element.para_type === 2) {
for (const image of element.pic.pics) {
description += `<p ><img src="${image.url}@progressive.webp"></p>`;
}
}
if (element.para_type === 3 && element.line?.pic?.url) {
} else if (element.para_type === 3 && element.line?.pic?.url) {
description += `<figure><img src="${element.line.pic.url}"></figure>`;
}
}
+9 -7
View File
@@ -52,14 +52,16 @@ async function handler(ctx) {
for (const parentArea of nameResponse.data.data) {
for (const area of parentArea.list) {
if (area.id === areaID) {
parentTitle = parentArea.name;
const parentID: string = parentArea.id;
areaTitle = area.name;
// cateID = area.cate_id;
areaLink = `https://live.bilibili.com/p/eden/area-tags?parentAreaId=${parentID}&areaId=${areaID}`;
break;
if (area.id !== areaID) {
continue;
}
parentTitle = parentArea.name;
const parentID: string = parentArea.id;
areaTitle = area.name;
// cateID = area.cate_id;
areaLink = `https://live.bilibili.com/p/eden/area-tags?parentAreaId=${parentID}&areaId=${areaID}`;
break;
}
}
+2 -2
View File
@@ -50,7 +50,7 @@ interface SessionItem {
ack_ts: number;
session_ts: number;
unread_count: number;
last_msg: null | {
last_msg: {
sender_uid: number;
receiver_type: number;
receiver_id: number;
@@ -63,7 +63,7 @@ interface SessionItem {
msg_status: number;
notify_code: string;
msg_source: number;
};
} | null;
group_type: number;
can_fold: number;
status: number;
+1 -1
View File
@@ -13,7 +13,7 @@ function formatDate(now) {
const year = now.getFullYear();
const month = now.getMonth() + 1;
const date = now.getDate();
const dateTime = year + '' + (month >= 10 ? month : '0' + month) + '' + (date >= 10 ? date : '0' + date);
const dateTime = year + '' + (month >= 10 ? month : '0' + month) + (date >= 10 ? date : '0' + date);
return dateTime;
}
+1 -1
View File
@@ -173,7 +173,7 @@
throw new Error('globalThis.TextDecoder is not available, polyfill required');
}
const encoder = new TextEncoder('utf-8');
const encoder = new TextEncoder();
const decoder = new TextDecoder('utf-8');
globalThis.Go = class {
+2 -2
View File
@@ -18,9 +18,9 @@ interface CatalogItem {
interface ArticleListResponse {
code: string;
data: null | {
data: {
catalogs: CatalogItem[];
};
} | null;
}
const TYPE_CATALOG_ID_MAP: Record<string, number> = {
+1 -1
View File
@@ -51,7 +51,7 @@ async function handler(ctx) {
const $ = load(iconv.decode(response.data, encoding));
const author = $('meta[property="og:novel:author"]').attr('content');
const pubDate = timezone(parseDate($('meta[property="og:novel:update_time"]').attr('content')), +8);
const pubDate = timezone(parseDate($('meta[property="og:novel:update_time"]').attr('content')), 8);
let items = $('dl dd a')
.toArray()
+1 -1
View File
@@ -50,7 +50,7 @@ const ProcessFeed = (base, list, caches) =>
.text()
.match(/\d{4}-\d{2}-\d{2}/)
),
+8
8
);
// 使用tryGet方法从缓存获取内容。
+1 -1
View File
@@ -37,7 +37,7 @@ const ProcessFeed = (base, list, caches) =>
.text()
.match(/\d{4}-\d{2}-\d{2}/)
),
+8
8
);
// 使用tryGet方法从缓存获取内容。
+1 -1
View File
@@ -20,7 +20,7 @@ async function loadContent(link) {
.text()
.match(/\d{4}(?:\/\d{2}){2}/)
),
+8
8
);
// 提取内容
+2 -2
View File
@@ -29,8 +29,8 @@ async function handler(ctx) {
const list = res.data.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 15).map((e) => ({
title: e.row.title,
guid: e.uuid,
pubDate: timezone(parseDate(e.row.publish_time), +8),
updated: timezone(parseDate(e.row.update_time), +8),
pubDate: timezone(parseDate(e.row.publish_time), 8),
updated: timezone(parseDate(e.row.update_time), 8),
link: `https://www.bjnews.com.cn/detail/${e.uuid}.html`,
}));
+1 -1
View File
@@ -11,7 +11,7 @@ export function fetchArticle(item) {
const $d = load(responses);
// $d('img').each((i, e) => $(e).attr('referrerpolicy', 'no-referrer'));
item.pubDate = timezone(parseDate($d('.left-info .timer').text()), +8);
item.pubDate = timezone(parseDate($d('.left-info .timer').text()), 8);
item.author = $d('.left-info .reporter').text();
item.description = $d('#contentStr').html();

Some files were not shown because too many files have changed in this diff Show More