Ignore trailing slashes when comparing place URLs
There's two locations where place URLs are compared in Dolphin. One
is in DolphinContextMenu::placeExists, which determines whether or not
to show an "Add to Places" context menu entry. The other one is in
DolphinViewContainer::caption, which provides the place name for use in
the window title, if applicable.
Neither of these functions correctly normalize the URL to account for
trailing slashes. Whilst placeExists() does not even attempt it,
caption() was changed in
681d8bb6c (Fix wrong window titles, 2019-09-15)
to support this using a regular expression.
However, caption() fails to escape the URL before incorporating it in
the regular expression, leading to failed matches and errors like the
following when browsing to directories that do not happen to make up a
valid regular expression:
QString(View)::contains(): called on an invalid QRegularExpression
object (pattern is '\A(?:file:///home/foo/[Z-A]/?)\z')
Instead of relying on complex and possibly brittle regular expressions,
use KFilePlacesModel's closestItem() function to find the closest
matching URL and then finally check whether the normalized URLs match
exactly.