Skip to content

Commit

Permalink
QueuePage: strip trailing slash from "lsinfo" URI
Browse files Browse the repository at this point in the history
Fixes yet another database completion bug.
  • Loading branch information
MaxKellermann committed Sep 11, 2024
1 parent 2625f14 commit 718a919
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/QueuePage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,16 @@ QueuePage::OnSongChange(const struct mpd_status *status)

#ifndef NCMPC_MINI
static void
add_dir(Completion &completion, const char *dir,
add_dir(Completion &completion, std::string_view uri,
struct mpdclient &c)
{
assert(uri.ends_with('/'));
/* strip the trailing slash (because MPD doesn't accept paths
ending with a slash) */
uri.remove_suffix(1);

completion.clear();
gcmp_list_from_path(c, dir, completion, GCMP_TYPE_RFILE);
gcmp_list_from_path(c, std::string{uri}.c_str(), completion, GCMP_TYPE_RFILE);
}

class DatabaseCompletion final : public Completion {
Expand Down Expand Up @@ -266,7 +271,7 @@ DatabaseCompletion::Pre(std::string_view line) noexcept
const auto [it, inserted] = dir_list.emplace(line);
if (inserted)
/* add directory content to list */
add_dir(*this, it->c_str(), c);
add_dir(*this, line, c);
}
}

Expand All @@ -281,7 +286,7 @@ DatabaseCompletion::Post(std::string_view line, Range range) noexcept
/* add directory content to list */
const auto [it, inserted] = dir_list.emplace(line);
if (inserted)
add_dir(*this, it->c_str(), c);
add_dir(*this, line, c);
}
}

Expand Down

0 comments on commit 718a919

Please sign in to comment.