Skip to content

OGC API / Handle the case when the root document is situated at the / path #104

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

Merged
merged 4 commits into from
Jun 19, 2025

Conversation

jahow
Copy link
Member

@jahow jahow commented Jun 18, 2025

jahow added 4 commits June 18, 2025 22:34
Make sure we always put a trailing slash when on the "app context" part of
the URL (the first segment after the root slash); this maximizes compatibility

Also make sure that we can still end up on the root "/" path because the root
document might be there
@jahow jahow requested a review from Copilot June 19, 2025 09:24
Copy link

@Copilot 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 improves URL handling for cases where the root document is located at the "/" path, ensuring that the expected trailing slash behavior is correctly applied. Key changes include:

  • Updated getParentPath logic in src/shared/url-utils.ts for better trailing slash and parent path handling.
  • Removed redundant trailing slash normalization in src/ogc-api/link-utils.ts to rely on the updated URL utilities.
  • Adjusted tests in src/ogc-api/endpoint.spec.ts and src/shared/url-utils.spec.ts to verify the correct behavior with root and collection paths.

Reviewed Changes

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

Show a summary per file
File Description
src/shared/url-utils.ts Revised getParentPath logic to remove trailing slashes when needed and to handle app context.
src/shared/url-utils.spec.ts Added tests to cover trailing slash behavior and edge cases for root vs. non-root URLs.
src/ogc-api/link-utils.ts Removed code that appended a trailing slash for collections; now uses getParentPath output directly.
src/ogc-api/endpoint.spec.ts Updated tests, including a fallback for root paths and adjustment of expected arrays.
fixtures/ogc-api/* New and updated fixtures to support OGC API endpoint verification.
Comments suppressed due to low confidence (3)

src/shared/url-utils.ts:15

  • [nitpick] Consider adding a comment to clarify the purpose of appending a trailing slash for the app context case.
  if (pathParts.length === 2 && pathParts[1] !== '') {

src/ogc-api/endpoint.spec.ts:21

  • [nitpick] Consider fixing the test description to properly close the parenthesis for clarity.
      return {

src/ogc-api/link-utils.ts:36

  • [nitpick] The previous logic automatically appended a trailing slash for collections; please confirm that this change is intentional and that URL normalization is handled consistently.
      const parentUrl = getParentPath(url);

@jahow jahow merged commit dec0c85 into main Jun 19, 2025
1 check passed
@jahow jahow deleted the ogc-api-handle-root-link branch June 19, 2025 10:14
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