fileurltolocalpath: Only remove fragment indicator from url if path looks like an html file

--HG--
branch : WINDOWSPORT
This commit is contained in:
Jean-Francois Dockes 2015-09-04 11:35:09 +02:00
parent 97950bfa60
commit 41b838fbed

View File

@ -805,6 +805,7 @@ string fileurltolocalpath(string url)
url = url.substr(7, string::npos); url = url.substr(7, string::npos);
else else
return string(); return string();
#ifdef _WIN32 #ifdef _WIN32
// Absolute file urls are like: file:///c:/mydir/... // Absolute file urls are like: file:///c:/mydir/...
// Get rid of the initial '/' // Get rid of the initial '/'
@ -812,10 +813,17 @@ string fileurltolocalpath(string url)
url = url.substr(1); url = url.substr(1);
} }
#endif #endif
// 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; string::size_type pos;
if ((pos = url.find_last_of("#")) != string::npos) { if ((pos = url.rfind(".html#")) != string::npos) {
url.erase(pos); url.erase(pos+5);
} else if ((pos = url.rfind(".htm#")) != string::npos) {
url.erase(pos+4);
} }
return url; return url;
} }
@ -1192,7 +1200,7 @@ int main(int argc, const char **argv)
pidfile.remove(); pidfile.remove();
#endif #endif
#if 1 #if 0
if (argc > 1) { if (argc > 1) {
cerr << "Usage: thumbpath <filepath>" << endl; cerr << "Usage: thumbpath <filepath>" << endl;
exit(1); exit(1);
@ -1224,6 +1232,19 @@ int main(int argc, const char **argv)
cout << "Suffix: [" << ext << "]" << endl; cout << "Suffix: [" << ext << "]" << endl;
return 0; return 0;
#endif #endif
#if 1
if (argc != 1) {
cerr << "Usage: trpathut url" << endl;
exit(1);
}
string url = *argv++;argc--;
cout << "File: [" << fileurltolocalpath(url) << "]\n";
return 0;
#endif
} }
#endif // TEST_PATHUT #endif // TEST_PATHUT