Add a trailing slash to the SFTP url for a directory - #2593
Conversation
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
|
All contributors have signed the CLA ✍️ ✅ |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesSFTP URL normalization
Priority: ➖ Normal Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
|
I have read the CLA Document and I hereby sign the CLA |
|
Thank you @duckducktw and @notAreYouScared ! |
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:sftp://user.uuid@host:2022/datasftp://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.phpcovers 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.Also ran locally on this branch:
composer pint,composer phpstan, andvendor/bin/pest tests/Unit(226 passed).Checklist