Skip to content

feat: support multiple rules#20

Merged
SoonIter merged 5 commits intomainfrom
syt/multipl-rule-support
Jul 2, 2025
Merged

feat: support multiple rules#20
SoonIter merged 5 commits intomainfrom
syt/multipl-rule-support

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Jun 25, 2025

feat: support multiple rules

the reimplementation of #21

close #21

1.7kb -> 1.9kb

image image

Copilot AI review requested due to automatic review settings June 25, 2025 12:01

This comment was marked as outdated.

@SoonIter SoonIter force-pushed the syt/multipl-rule-support branch from 2244672 to 5f3ac04 Compare June 26, 2025 07:02
@SoonIter
Copy link
Copy Markdown
Member Author

@LuciferChiu cc

Comment thread src/runtime/utils/findMatchingRule.ts Outdated
Comment thread README.md Outdated
Comment thread src/runtime/utils/urlCalculate.ts
Comment thread src/runtime/utils/findMatchingRule.ts Outdated
Comment thread src/runtime/utils/findMatchingRule.ts Outdated
@SoonIter SoonIter requested a review from LuciferChiu June 30, 2025 09:48
@SoonIter SoonIter requested a review from chenjiahan July 1, 2025 08:36
@SoonIter SoonIter enabled auto-merge (squash) July 1, 2025 09:01
Comment thread README.md Outdated
@chenjiahan chenjiahan requested a review from Copilot July 1, 2025 09:11

This comment was marked as outdated.

@SoonIter SoonIter requested review from chenjiahan and Copilot July 2, 2025 05:00
@SoonIter
Copy link
Copy Markdown
Member Author

SoonIter commented Jul 2, 2025

image

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reimplements support for multiple retry rules by extending types, enhancing runtime logic, and updating documentation.

  • Allow test to be a RegExp and introduce a rules array in options
  • Implement rule-based matching and processing in both initial and async chunk retry runtimes
  • Update plugin entry to normalize multiple rules and refresh docs/examples

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/basic/multipleRules.test.ts Added end-to-end tests covering multiple rule scenarios
src/types.ts Extended test to accept RegExp and added rules union type
src/runtime/utils/urlCalculate.ts Refactored domain lookup and next-domain logic
src/runtime/utils/findMatchingRule.ts Added matching logic over test/domain/type
src/runtime/initialChunkRetry.ts Updated retry/load handlers to iterate over rules
src/runtime/asyncChunkRetry.ts Adapted async-chunk logic to pick and apply matching rule
src/index.ts Modified getRuntimeOptions to produce arrays of normalized rules
README.md Documented rules option and updated type signatures
README.zh-CN.md Introduced rules section and examples
Comments suppressed due to low confidence (4)

src/runtime/initialChunkRetry.ts:275

  • [nitpick] The parameter config holds an array of rules rather than a single config object. Rename it to rules to match its type and usage, improving clarity.
function load(config: NormalizedRuntimeRetryOptions[], e: Event) {

README.zh-CN.md:64

  • The test property can now also be a RegExp. Update the type to string | RegExp | ((url: string) => boolean) to align with the code.
  test?: string | ((url: string) => boolean);

src/runtime/utils/findMatchingRule.ts:1

  • The function refers to NormalizedRuntimeRetryOptions but the type isn't imported. Add import type { NormalizedRuntimeRetryOptions } from '../types.js'; at the top.
import { findCurrentDomain } from './urlCalculate.js';

src/runtime/utils/urlCalculate.ts:1

  • The signature uses NormalizedRuntimeRetryOptions but that type isn't imported. Please add import type { NormalizedRuntimeRetryOptions } from '../../types.js'; or the correct relative path.
export function findCurrentDomain(

@SoonIter SoonIter merged commit f970bed into main Jul 2, 2025
2 checks passed
@SoonIter SoonIter deleted the syt/multipl-rule-support branch July 2, 2025 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants