Skip to content

feat: support multiple rules #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 2, 2025
Merged

feat: support multiple rules #20

merged 5 commits into from
Jul 2, 2025

Conversation

SoonIter
Copy link
Member

@SoonIter SoonIter commented Jun 25, 2025

feat: support multiple rules

the reimplementation of #21

close #21

1.7kb -> 1.9kb

image image

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

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
Member Author

@LuciferChiu cc

@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
@chenjiahan chenjiahan requested a review from Copilot July 1, 2025 09:11
Copilot

This comment was marked as outdated.

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

SoonIter commented Jul 2, 2025

image

Copy link

@Copilot 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.

3 participants