Skip to content

Add a trailing slash to the SFTP url for a directory - #2593

Merged
lancepioch merged 1 commit into
pelican:mainfrom
duckducktw:fix/sftp-url-trailing-slash
Sep 22, 2026
Merged

lancepioch merged 1 commit into
pelican:mainfrom
duckducktw:fix/sftp-url-trailing-slash

Conversation

@duckducktw

Copy link
Copy Markdown
Contributor

Resolves #2577

What and why

The "Open current folder in SFTP" button produced a url without a trailing slash for any directory other than the server root, and SFTP clients only treat a url path as a directory when it ends with one. WinSCP therefore offered to download the path as a file (Download file .. to local directory:) instead of opening the folder — exactly what @notAreYouScared diagnosed in the issue.

For /data:

url
before sftp://user.uuid@host:2022/data
after sftp://user.uuid@host:2022/data/

The server root is deliberately left alone, since that case already opens the directory and the url carries no path there.

Tests

tests/Unit/Models/ServerTest.php covers the trailing slash for single, nested, trailing-slash and no-leading-slash directories, plus the url-encoding of path segments and of the username, and the node sftp alias.

PASS  App\Tests\Unit\Models\ServerTest  (9 tests, 9 assertions)

Also ran locally on this branch: composer pint, composer phpstan, and vendor/bin/pest tests/Unit (226 passed).

Checklist

  • This pull request does one thing (unrelated changes are split into separate pull requests)
  • New translation strings are added to English only (other languages come from Crowdin) — no new strings
  • UI changes include before/after screenshots — no visual change; the urls in the table above are the before/after, and a screenshot needs a Windows SFTP client to show

SFTP clients only treat a url path as a directory when it ends with a
slash. Without one they offer to download the path as a file instead of
opening it, which is what the "Open current folder in SFTP" button did
for every directory except the server root.

Closes pelican#2577
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5c76b889-29db-433b-ae16-49bf636b5294

📥 Commits

Reviewing files that changed from the base of the PR and between fa82576 and 0de2ada.

📒 Files selected for processing (2)
  • app/Models/Server.php
  • tests/Unit/Models/ServerTest.php

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Server::getSftpUrl() now adds a trailing slash to non-root directory paths. New unit tests cover path normalization, encoded values, SFTP aliases, and usernames.

Changes

SFTP URL normalization

Layer / File(s) Summary
Normalize and validate SFTP directory URLs
app/Models/Server.php, tests/Unit/Models/ServerTest.php
Server::getSftpUrl() preserves the root path and appends / to other encoded directory paths. Tests cover null and varied directory inputs, SFTP aliases, percent-encoded usernames, and server setup.

Priority: ➖ Normal

Severity of issue fixed: Medium

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. 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 clearly identifies the main change: adding a trailing slash to SFTP URLs for directory paths.
Description check ✅ Passed The description explains the issue, the expected behavior, the root-directory exception, the tests, and the validation results. It directly relates to the changeset.
Linked Issues check ✅ Passed The change addresses #2577. Server::getSftpUrl() appends / to non-root directory paths, so SFTP clients can treat subdirectories as directories. The root path remains unchanged. Tests cover root a…
Out of Scope Changes check ✅ Passed The changes stay within #2577. They modify SFTP URL generation and add focused unit tests for that behavior. No unrelated production behavior or unrelated tests are changed.
  • Fix all pre-merge checks with AI

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.

@duckducktw

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@lancepioch lancepioch self-assigned this Sep 22, 2026
@lancepioch
lancepioch merged commit 3d0d4dc into pelican:main Sep 22, 2026
19 of 20 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
@lancepioch

Copy link
Copy Markdown
Member

Thank you @duckducktw and @notAreYouScared !

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.

SFTP button in the Folder Viewer doesn't work as expected

2 participants