fix: solution for issue #19 - #29
Open
adityawaghamare04 wants to merge 1 commit into
Open
Conversation
6 tasks
|
这个 PR 已经 7 天没有新提交、作者也没有回复,它关联任务上的托管因此一直被占着,既不结算也不释放。
PR 不会被关闭——这是你的工作,随时可以接着做。被释放的只是任务上的认领,任务重新开放给其他人。 如果你还在做,回一句就行。 No commits or author replies for 7 days. The claim is released; this PR stays open. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix & Proposed Solution
Closes #19
🛠️ Proposed Solution (by Aditya Waghamare)
Analysis
The current
stripPrefixoption insparepackonly allows stripping a single prefix string from destination paths. In complex directory structures (monorepos, separate config/test/src dirs), a single prefix is insufficient.To support general path remapping,
stripPrefixis generalised intoremap—an ordered list of{ from, to }mappings where the first matching rule applies. Traversal checks are enforced both on the configured values (from/to) and on the post-remap destination paths.stripPrefixremains as syntactic sugar for{ from: prefix, to: "" }.Fix Implementation
1. Configuration Validation & Normalisation (
src/config.mjs)remapinKNOWN_KEYS.remaparray structure (fromandtostrings).fromandtovalues (rejecting absolute paths, leading slashes, and..path traversal segments).stripPrefixintoremap: [{ from: stripPrefix, to: "" }]whenremapis not explicitly provided.2. Path Processing, Traversal & Collision Check (
src/pack.mjs)remaprules (first match wins).remaprule fails to match at least one file...or absolute paths).MANIFEST.json.3. Update Init Template & README
sparepack inittemplate (src/init.mjs/template.json) to demonstrateremap.README.mddocumentation explainingremapsyntax, ordering semantics, and backwards compatibility withstripPrefix.Testing
Added comprehensive unit tests in
test/remap.test.mjs:All 84+ unit and integration tests pass successfully!
Submitted by Aditya Waghamare
💰 Payout Address (Base L2 / EVM):
0xb61dBcdBc3407F71EaCb64D4CBFAcf9FFfe2415C