Skip to content

Fix trailing slash of untold torment and suffering#2319

Closed
karaolidis wants to merge 1 commit into
pelican-dev:mainfrom
karaolidis:pain
Closed

Fix trailing slash of untold torment and suffering#2319
karaolidis wants to merge 1 commit into
pelican-dev:mainfrom
karaolidis:pain

Conversation

@karaolidis
Copy link
Copy Markdown
Contributor

When Pelican is deployed behind a reverse proxy (e.g., Traefik, nginx) that terminates TLS and forwards plain HTTP to Apache, navigating to the file editor triggers a mixed content block in the browser.

Why? EditFiles::getUrl() appends a trailing / to the URL. The .htaccess rewrite rule then strips it with a 301 Redirect. When Apache constructs the redirect URL, it uses the scheme of the incoming connection (plain http://), not the external-facing scheme. The browser sees a redirect from https:// to http:// and blocks it as mixed active content.

The fix simply removes the trailing slash concatenation. The redirect was always a no-op from the user's perspective (append slash, immediately redirect to remove it), and Laravel's front controller handles routing regardless of trailing slashes.

I have run out of hairs to pull out debugging this.

Possibly relevant to #1685.

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Walkthrough

The getUrl() method in EditFiles page is modified to return the parent URL without appending a trailing slash. Previously, a trailing slash was concatenated to the parent URL.

Changes

EditFiles URL Generation

Layer / File(s) Summary
URL Generation
app/Filament/Server/Resources/Files/Pages/EditFiles.php
The getUrl() method updated to return parent::getUrl(...) without appending a trailing slash character.

Possibly Related PRs

  • pelican-dev/panel#1925: Adjusts breadcrumb URL construction in EditFiles to use ListFiles::getUrl() instead of self::getUrl().
  • pelican-dev/panel#2171: Addresses the same trailing-slash redirect issue affecting the EditFiles page.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses humorous/colloquial language ('untold torment and suffering') but clearly refers to the core change: removing a trailing slash that causes issues. It adequately summarizes the main fix.
Description check ✅ Passed The description is directly related to the changeset, providing detailed context about the trailing slash issue, its root cause in reverse proxy scenarios, and the rationale for the fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/Filament/Server/Resources/Files/Pages/EditFiles.php (1)

262-265: ⚡ Quick win

getUrl() override is now a no-op — consider removing it entirely.

After stripping the trailing-slash concatenation, this override unconditionally delegates to parent::getUrl() with identical arguments and adds no behaviour. Keeping it is misleading (readers will wonder what it overrides) and means future changes to the parent signature must be mirrored here manually.

♻️ Proposed refactor — remove the redundant override
-    public static function getUrl(array $parameters = [], bool $isAbsolute = true, ?string $panel = null, ?Model $tenant = null, bool $shouldGuessMissingParameters = false, ?string $configuration = null): string
-    {
-        return parent::getUrl($parameters, $isAbsolute, $panel, $tenant, $shouldGuessMissingParameters, $configuration);
-    }
-
     public static function route(string $path): PageRegistration
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Filament/Server/Resources/Files/Pages/EditFiles.php` around lines 262 -
265, The getUrl method override in the EditFiles page is now a no-op and should
be removed: delete the public static function getUrl(...) definition so the
class inherits parent::getUrl() directly; verify there are no internal
references to EditFiles::getUrl elsewhere (search for getUrl calls on this
class) and run tests/compile to ensure no signature-dependent code required the
override.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/Filament/Server/Resources/Files/Pages/EditFiles.php`:
- Around line 262-265: The getUrl method override in the EditFiles page is now a
no-op and should be removed: delete the public static function getUrl(...)
definition so the class inherits parent::getUrl() directly; verify there are no
internal references to EditFiles::getUrl elsewhere (search for getUrl calls on
this class) and run tests/compile to ensure no signature-dependent code required
the override.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e541b915-7254-4d04-9d75-c3ea57667d6a

📥 Commits

Reviewing files that changed from the base of the PR and between d520224 and f004430.

📒 Files selected for processing (1)
  • app/Filament/Server/Resources/Files/Pages/EditFiles.php

@karaolidis
Copy link
Copy Markdown
Contributor Author

karaolidis commented May 6, 2026

getUrl() override is now a no-op — consider removing it entirely.

I'll leave this one up to the maintainers.

edit: i.e. the decision, not the cleanup

@QuintenQVD0
Copy link
Copy Markdown
Contributor

It is needed else you can't edit .env files or .php files for example.

Copy link
Copy Markdown
Member

@rmartinoscar rmartinoscar left a comment

Choose a reason for hiding this comment

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

Hey thanks for your contribution but im afraid without that you won't be able to edit files that start with a dot or are processed by your webserver such as .html, .php etc...

@Boy132 Boy132 closed this May 6, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants