Skip to content

Support file: protocol in link urls#291

Merged
kamilkisiela merged 8 commits intomainfrom
file-protocol-link-urls
Mar 17, 2026
Merged

Support file: protocol in link urls#291
kamilkisiela merged 8 commits intomainfrom
file-protocol-link-urls

Conversation

@jdolle
Copy link
Copy Markdown
Contributor

@jdolle jdolle commented Mar 16, 2026

File protocols are valid RFC 3986 and should be supported. Also adds support for non-RFC 3986 per the federation link spec

@jdolle jdolle requested a review from kamilkisiela March 16, 2026 19:24
@jdolle jdolle self-assigned this Mar 16, 2026
@jdolle jdolle added the bug Something isn't working label Mar 16, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 introduces comprehensive support for the file: protocol in link URLs, ensuring that local file system references are correctly parsed and handled within the system. This enhancement aligns the URL parsing logic with RFC 3986, improving the robustness and flexibility of how links are interpreted, particularly for local development or specific deployment scenarios.

Highlights

  • File Protocol Support: Introduced support for file: protocol URLs, allowing local file system references to be correctly parsed and handled.
  • Enhanced URL Parsing Logic: Updated the parseLinkUrl function and FederatedLinkUrl class to accurately extract name, version, and identity from file: URLs, addressing cases where URL.origin returns null for file: protocols.
  • Improved Version Detection: Refined the logic for identifying version strings in URLs, ensuring that only valid version patterns (e.g., v1.0) are recognized as versions.
  • Expanded Test Coverage: Added new test cases in link-url.spec.ts and link.spec.ts to validate the correct parsing behavior for file: protocol URLs.
  • Documentation Update: Updated the inline documentation in src/specifications/link.ts to include an example of a file: protocol URL.
Changelog
  • .changeset/eager-lilies-walk.md
    • Added a new changeset file to document the patch for @theguild/federation-composition.
  • tests/utils/link-url.spec.ts
    • Added a test case to verify fromUrl correctly parses file:///extensions/permissions.
  • src/specifications/link.spec.ts
    • Added a test case to verify parseLinkUrl correctly parses file:///extensions/permissions.
    • Updated an existing test case for https://spec.example.com/mySchema/not-a-version to correctly reflect its name and identity.
  • src/specifications/link.ts
    • Modified parseLinkUrl to handle file: protocol URLs by explicitly setting the origin to file:// when url.protocol is file:.
    • Refined the logic for determining name and version by introducing lastIsVersion check.
    • Updated the documentation table to include an example for file:///extensions/permissions.
  • src/utils/link/link-url.ts
    • Modified FederatedLinkUrl.fromUrl to correctly determine the origin for file: protocol URLs, using file:// instead of url.origin which can be null.
Activity
  • No specific activity has been recorded for this pull request yet.
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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@theguild/federation-composition 0.22.1-alpha-20260317100310-e5a0fc08ebf912119609832cfa4df0591fbdce3c npm ↗︎ unpkg ↗︎

Copy link
Copy Markdown
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 adds support for file: protocol in link URLs, which is a valid URI scheme. The changes correctly handle the file: protocol by providing a fallback for the origin, as Node.js's URL parser can return null for file: URLs. Additionally, the PR includes a fix for parsing URLs where the last path segment is not a version string, improving the robustness of the URL parsing logic. The tests have been updated accordingly. I've found a couple of minor issues in the documentation comments that I've pointed out.

jdolle and others added 7 commits March 16, 2026 12:52
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@kamilkisiela kamilkisiela merged commit ec0ef84 into main Mar 17, 2026
4 checks passed
@kamilkisiela kamilkisiela deleted the file-protocol-link-urls branch March 17, 2026 10:05
n1ru4l pushed a commit that referenced this pull request Mar 17, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @theguild/federation-composition@0.22.1

### Patch Changes

-
[#291](#291)
[`ec0ef84`](ec0ef84)
Thanks [@jdolle](https://github.com/jdolle)! - Support "file:" protocol
and non-RFC 3986 in imported "link" url argument

-
[#282](#282)
[`e507fdd`](e507fdd)
Thanks [@kamilkisiela](https://github.com/kamilkisiela)! - Fix
supergraph `@join__field` emission for Federation v1 `@external` fields
and improve override/requires edge-case handling.
- Drop Federation v1 `@join__field(external: true)` fields based on key
usage in the subgraph instead of aggregated field key usage across
subgraphs.
- Avoid emitting redundant `@join__field(external: true)` metadata when
a field is only required through overridden paths.
- Tighten `@join__field` emission around `@override` and interface type
fields.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants