Skip to content
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

fix: support windows directory detect #106

Merged
merged 2 commits into from
May 23, 2024
Merged

Conversation

grj001
Copy link
Contributor

@grj001 grj001 commented May 22, 2024

fix window file separator

Summary by CodeRabbit

  • Bug Fixes
    • Improved directory detection in zip files to handle both backslashes and forward slashes, ensuring better compatibility across different operating systems.

fix window file separator
Copy link

coderabbitai bot commented May 22, 2024

Walkthrough

The update focuses on enhancing directory detection in the ZipUncompressStream class within lib/zip/uncompress_stream.js. By refining the regular expression to identify directories based on trailing backslashes and forward slashes in the file name, the uncompression process becomes more robust and adaptable across various platforms.

Changes

File Path Change Summary
lib/zip/uncompress_stream.js Updated the regular expression to detect directories by checking for both backslashes and forward slashes.

Possibly related issues

Poem

In code we trust, to mend and fix,
With slashes both, no more conflicts.
Directories now, clear and bright,
Unzipping files, day and night.
A rabbit's touch, soft and light,
Ensures our streams unzip just right. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

sweep-ai bot commented May 22, 2024

Sweep: PR Review

Authors of pull request: @grj001

lib/zip/uncompress_stream.js

Enhanced directory name detection to support both forward and backslashes as terminators.

Sweep Found These Issues

  • The updated regular expression may incorrectly identify file names ending with a backslash as directories, which could lead to incorrect handling of such files.
  • // directory file names end with '/'
    const type = /[\\\/]$/.test(entry.fileName) ? 'directory' : 'file';
    const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);

    View Diff


Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7043a9c and 64482e0.
Files selected for processing (1)
  • lib/zip/uncompress_stream.js (1 hunks)
Additional comments not posted (1)
lib/zip/uncompress_stream.js (1)

102-102: Updated regex to handle both backslashes and forward slashes is appropriate for cross-platform compatibility.

Verification successful

The rg search found multiple usages of entry.fileName in lib/zip/uncompress_stream.js. Here are the relevant lines:

  • lib/zip/uncompress_stream.js: if (Buffer.isBuffer(entry.fileName)) {
  • lib/zip/uncompress_stream.js: entry.fileName = entry.fileName.toString();
  • lib/zip/uncompress_stream.js: entry.fileName = iconv.decode(entry.fileName, this._zipFileNameEncoding);
  • lib/zip/uncompress_stream.js: const type = /[\\\/]$/.test(entry.fileName) ? 'directory' : 'file';
  • lib/zip/uncompress_stream.js: const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);

The regex change appears in the context of determining the type of the entry (directory or file). The other usages involve converting entry.fileName to a string and decoding it, which should not be affected by the regex change.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the updated regex does not affect other parts of the system.

# Test: Search for other usages of `entry.fileName` that might be affected by the regex change.
rg --type javascript $'entry.fileName'

Length of output: 72



Script:

#!/bin/bash
# Description: Verify that the updated regex does not affect other parts of the system.

# Test: Search for other usages of `entry.fileName` that might be affected by the regex change.
rg --type js 'entry.fileName'

Length of output: 517

@fengmk2 fengmk2 changed the title Update uncompress_stream.js fix: support windows directory detect May 23, 2024
@fengmk2 fengmk2 added the bug label May 23, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 64482e0 and 8da569b.
Files selected for processing (1)
  • lib/zip/uncompress_stream.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • lib/zip/uncompress_stream.js

@fengmk2 fengmk2 merged commit 122091b into node-modules:master May 23, 2024
17 checks passed
fengmk2 pushed a commit that referenced this pull request May 23, 2024
[skip ci]

## [1.10.1](v1.10.0...v1.10.1) (2024-05-23)

### Bug Fixes

* support windows directory detect ([#106](#106)) ([122091b](122091b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants