util: Add StripRedundantLastElementsOfPath function
Summary:
This fixes a bug causing listwalletdir to strip lead char of wallet name is datadir has a trailing '/'
Co-authored-by: saibato <saibato.naga@pm.me>
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This is a backport of core#20080
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D10693