From bf779aca37532f525530b753cb2b6fccfe538abd Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Mon, 14 Sep 2015 17:10:24 +0200 Subject: [PATCH] only remove a fragment part from a file name if it looks like an html --- src/utils/pathut.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 4b6d1a58..1e9b4799 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -562,10 +562,17 @@ string fileurltolocalpath(string url) url = url.substr(7, string::npos); else return string(); + + // Removing the fragment part. This is exclusively used when + // executing a viewer for the recoll manual, and we only strip the + // part after # if it is preceded by .html string::size_type pos; - if ((pos = url.find_last_of("#")) != string::npos) { - url.erase(pos); + if ((pos = url.rfind(".html#")) != string::npos) { + url.erase(pos+5); + } else if ((pos = url.rfind(".htm#")) != string::npos) { + url.erase(pos+4); } + return url; }