-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
2244672
to
5f3ac04
Compare
@LuciferChiu cc |
There was a problem hiding this 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 aRegExp
and introduce arules
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 torules
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 aRegExp
. Update the type tostring | 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. Addimport 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 addimport type { NormalizedRuntimeRetryOptions } from '../../types.js';
or the correct relative path.
export function findCurrentDomain(
feat: support multiple rules
the reimplementation of #21
close #21
1.7kb -> 1.9kb