Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,12 @@ testUrlDecodingNonLatinLanguages()
## - Options are the same for all URLs (except --next)
## - URLs beginning with '-' (with and without using '--')

testFragmentStripping()
{
url='example.com/document.pdf#page=5'
ret=$(${WCURL_CMD} "${url}" 2>&1 | tr '\n' ' ')
assertContains "Verify whether 'wcurl' correctly strips #fragments from filenames" "${ret}" '--output document.pdf '
}

# shellcheck disable=SC1091
. shunit2
2 changes: 1 addition & 1 deletion wcurl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ percent_decode()
get_url_filename()
{
# Remove protocol and query string if present.
hostname_and_path="$(printf %s "${1}" | sed -e 's,^[^/]*//,,' -e 's,?.*$,,')"
hostname_and_path="$(printf %s "${1}" | sed -e 's,^[^/]*//,,' -e 's,[?#].*$,,')"
# If what remains contains a slash, there is a path; return it percent-decoded.
case "${hostname_and_path}" in
# sed to remove everything preceding the last '/', e.g.: "example/something" becomes "something"
Expand Down