Make it possible to change directory up even with trailing slashes in the url
ClosedPublic

Authored by jtamate on Jun 22 2018, 10:48 AM.

Details

Summary

Normalize the paths in KUriFilterData.
Normalize the path in cdUp (leave only the last / in the url) before going up.

Test Plan

The url of a ntfs partition is file:///d//. When I pressed cdUp, it remained in the same directory instead of going to root.
Now even if I write urls like

/d/c///////////////////////

when I press cdUp it goes up to /d/ and when I press Enter, the url stored in the history is /d/c/.

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jtamate created this revision.Jun 22 2018, 10:48 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 22 2018, 10:48 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
jtamate requested review of this revision.Jun 22 2018, 10:48 AM
dfaure requested changes to this revision.Jun 22 2018, 11:29 AM

I think you want QUrl::NormalizePathSegments, which would make this code simpler (and would also handle a initial URL like /d/c/../ if it can make it to that code path)

This revision now requires changes to proceed.Jun 22 2018, 11:29 AM
jtamate updated this revision to Diff 36513.Jun 22 2018, 11:57 AM

Using NormalizePathSegments.

There is something else going on with the trailing slashes in the file dialog.
If I'm in my home directory and I append slashes, they are removed, also in /, but in /home/ and other directories they are not removed, and every time I end up in /home/ the text in the url is /home/// (not in the breadcrumb).

dfaure added a comment.Jul 6 2018, 8:15 AM

Unittests would help ;)

jtamate updated this revision to Diff 37500.Jul 10 2018, 11:57 AM
jtamate edited the summary of this revision. (Show Details)
jtamate edited the test plan for this revision. (Show Details)

The url in the lineedit is get from KUriFilterData, and it didn't normalize the paths, allowing trailing slashes.
Include 4 new tests and fix 2 (the ones with // in the middle of the urls).

dfaure accepted this revision.Sep 17 2018, 5:22 PM
This revision is now accepted and ready to land.Sep 17 2018, 5:22 PM
This revision was automatically updated to reflect the committed changes.