gruns / gruns/furl

.join() and .path.normalize() incorrectly interpret base paths ending /. or /..

Open
#159 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.8k
Forks
165
PR merge metrics
No merged PRs in 30d

Description

When joining URLs, furl correctly treats a path `/a/b/c/d/../` as equivalent to `/a/b/c/`, but it incorrectly treats `/a/b/c/d/..` as equivalent to `/a/b/c` rather than `/a/b/c/` (with a trailing slash). This causes further path components to be joined at the wrong level.

```pycon
>>> furl("http://host/a/b/c/d/../").join("D") # correct
furl('http://host/a/b/c/D')
>>> furl("http://host/a/b/c/d/..").join("D") # expected furl('http://host/a/b/c/D')
furl('http://host/a/b/c/d/D')
```

A similar problem can be observed with `.path.normalize()`. This one also affects paths ending in `/.`:

```pycon
>>> furl("http://host/a/b/c/d/./").path.normalize() # correct
Path('/a/b/c/d/')
>>> furl("http://host/a/b/c/d/../").path.normalize() # correct
Path('/a/b/c/')
>>> furl("http://host/a/b/c/d/.").path.normalize() # expected Path('/a/b/c/d/')
Path('/a/b/c/d')
>>> furl("http://host/a/b/c/d/..").path.normalize() # expected Path('/a/b/c/')
Path('/a/b/c')
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.