Skip to content

fix package extension#6835

Merged
waruqi merged 2 commits intodevfrom
package
Sep 20, 2025
Merged

fix package extension#6835
waruqi merged 2 commits intodevfrom
package

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Sep 20, 2025

@waruqi waruqi added this to the v3.0.3 milestone Sep 20, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @waruqi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the package download process by implementing a more robust method for identifying file extensions. A new utility function, _url_extension, has been introduced to ensure that both archive and non-archive files are correctly named and handled, thereby improving the overall reliability of package acquisition within the system.

Highlights

  • New Utility Function: Introduced a new helper function, _url_extension, which intelligently determines file extensions by first checking for known archive types and then falling back to general path extensions for broader compatibility.
  • Improved Package File Naming: Updated the package download logic to utilize the new _url_extension function, ensuring more accurate and robust file naming for downloaded packages, especially for non-archive files.
  • Enhanced File Type Handling: The changes improve the system's ability to correctly handle various file types during download, preventing potential issues with file identification and extraction by providing a more comprehensive extension detection mechanism.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a fix to correctly handle package extensions for non-archive files, such as .exe or .sh. This is achieved by adding a new helper function, _url_extension, and using it in place of archive.extension where appropriate. The change is logical and correctly addresses the issue. However, I've identified a potential issue in the new helper function where URLs with query parameters are not handled correctly, which could lead to incorrect extension parsing. I have provided a suggestion to make the function more robust.

Comment on lines +38 to +45
function _url_extension(url)
local extension = archive.extension(url)
if extension == "" then
-- maybe non-archive file, e.g. .exe, .sh, ..
extension = path.extension(url)
end
return extension
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The new _url_extension function does not correctly handle URLs that contain query parameters (e.g., https://example.com/file.zip?token=...). This can result in an incorrect extension like .zip?token=... being extracted. To ensure robustness, the query string should be stripped from the URL before attempting to determine the file extension.

function _url_extension(url)
    local urlpath = url:split('?', {plain = true})[1]
    local extension = archive.extension(urlpath)
    if extension == "" then
        -- maybe non-archive file, e.g. .exe, .sh, ..
        extension = path.extension(urlpath)
    end
    return extension
end

@waruqi waruqi merged commit 27a68c7 into dev Sep 20, 2025
44 checks passed
@waruqi waruqi deleted the package branch September 20, 2025 12:37
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.

1 participant