Skip to content

fix: encode resource names in spx resource URIs#2956

Merged
nighca merged 1 commit intogoplus:devfrom
nighca:issue-2955
Mar 17, 2026
Merged

fix: encode resource names in spx resource URIs#2956
nighca merged 1 commit intogoplus:devfrom
nighca:issue-2955

Conversation

@nighca
Copy link
Collaborator

@nighca nighca commented Mar 17, 2026

Summary

  • encode resource names when generating spx resource URIs
  • add parsing coverage for encoded resource names
  • add tests for encoded URIs generated from resource models

Testing

  • npm test

Related

Copilot AI review requested due to automatic review settings March 17, 2026 01:45
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 addresses an issue where SPX resource URIs might not correctly handle special characters in resource names. By directly applying URI encoding when generating resource URIs and enhancing the parsing logic, the system now ensures robust and consistent handling of resource identifiers, improving overall reliability.

Highlights

  • Resource URI Encoding: Implemented direct URI encoding for resource names in getResourceURI by replacing the temporary encodeResourceName function with encodeURIComponent.
  • Removed Temporary Encoding Flag: The shouldEncodeResourceName flag and its associated encodeResourceName utility were removed, indicating that URI encoding is now a standard practice.
  • Enhanced Test Coverage: Added new test cases to verify the correct parsing of URIs with encoded resource names and to ensure that getResourceURI properly encodes resource names when generating URIs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • spx-gui/src/components/editor/code-editor/spx-code-editor/common.test.ts
    • Added imports for various SPX model types (Animation, Backdrop, Costume, Sound, Sprite) and getResourceURI.
    • Expanded parseResourceURI tests to include cases with encoded resource names, such as those containing slashes or spaces.
    • Introduced a new test suite for getResourceURI to validate that resource names are correctly URI-encoded during URI generation for different resource types.
  • spx-gui/src/components/editor/code-editor/spx-code-editor/common.ts
    • Removed the shouldEncodeResourceName constant and the encodeResourceName helper function.
    • Modified the getResourceURI function to directly use encodeURIComponent for all resource names (Sprite, Sound, Backdrop, Costume, Animation, Widget) when constructing resource URIs.
Activity
  • The author has indicated that npm test was run to verify the changes.
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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

@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 correctly enables URI encoding for resource names and adds comprehensive tests to cover this change. The removal of the conditional encoding logic simplifies the code. I've added one suggestion in the test file to improve the readability and maintainability of the test setup by using a helper function to create mock resource objects.

Copy link
Contributor

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 enables proper URI encoding of resource names in spx resource URIs. Previously, encoding was intentionally disabled via a shouldEncodeResourceName flag due to a language server compatibility issue. Now that the language server handles encoded URIs correctly, the workaround is removed and encodeURIComponent is used directly.

Changes:

  • Removed the encodeResourceName wrapper function and its shouldEncodeResourceName flag, replacing all calls with native encodeURIComponent.
  • Added tests for getResourceURI verifying that special characters (slashes, spaces, #, &) are properly encoded.
  • Added parsing tests for encoded resource names to ensure round-trip correctness.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
spx-gui/src/components/editor/code-editor/spx-code-editor/common.ts Removed encodeResourceName helper; replaced with direct encodeURIComponent calls in getResourceURI.
spx-gui/src/components/editor/code-editor/spx-code-editor/common.test.ts Added getResourceURI encoding tests and additional parseResourceURI/parseResourceContextURI tests for encoded names.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xgopilot
Copy link
Contributor

xgopilot bot commented Mar 17, 2026

Clean, well-scoped fix. Removing the encodeResourceName workaround and switching directly to encodeURIComponent is the right call, and the encode/decode symmetry with parseResourceURI is maintained correctly. The test fixture pattern (Object.assign(Object.create(Model.prototype), ...)) correctly satisfies instanceof checks. Two minor notes left inline: missing Widget/Stage test coverage, and a suggestion to add a brief comment on getResourceURI recording the xgolsw version dependency.

@nighca nighca merged commit 39dfe1d into goplus:dev Mar 17, 2026
5 checks passed
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