Skip to content

Spec recommendation vs implementation inconsistency in resource URL trailing slash handling #1433

Closed as duplicate

Description

@younaman

Question

Description:
According to the specification (and RFC 8707 guidance), implementations SHOULD consistently use the form without the trailing slash for better interoperability, unless the trailing slash is semantically significant.

However, in the current implementation of check_resource_allowed, both requested_path and configured_path are normalized by adding a trailing slash before comparison:

if not requested_path.endswith("/"):
    requested_path += "/"
if not configured_path.endswith("/"):
    configured_path += "/"
return requested_path.startswith(configured_path)

This ensures correct boundary checks (avoiding /api123 matching /api), but it looks contradictory to the spec’s recommendation (which suggests preferring non-slash-terminated form).

Expected behavior:

  • Resource URLs should be canonicalized to the “no trailing slash” form wherever possible (e.g., inside resource_url_from_server_url), except when semantically required.
  • The comparison logic in check_resource_allowed can still normalize with / internally for boundary safety, but ideally this should be documented clearly to avoid confusion.

Actual behavior:

  • Implementation internally adds a trailing slash before comparison, which appears to promote the opposite style compared to the spec recommendation.

Suggestion:

  1. Canonicalize configured/requested URLs to the “no trailing slash” form (except root path /) when generating or storing resource URLs.
  2. Keep the internal endswith("/") normalization in check_resource_allowed for safe prefix matching.
  3. Update docstrings or comments to clarify why the implementation diverges from the spec’s recommended form, to avoid confusion for implementers.

Additional Context

No response

Activity

  1. added
    ready for workEnough information for someone to start working on
    P0Broken core functionality, security issues, critical missing feature
    on Oct 9, 2025
  2. felixweinberger commented on Oct 9, 2025

    @felixweinberger
    Contributor

    Saw issues around mount path / urls in a few places

  3. added
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    and removed
    P0Broken core functionality, security issues, critical missing feature
    on Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurequestionFurther information is requestedready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions