From f3975837c48284fdd21ac9d44c59af73d5ebd2fc Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Wed, 23 Nov 2022 20:40:19 +0800 Subject: [PATCH] fix: fix zim resource namespace remove possible namespace from the article,the namespace should follow the following pattern '/J/resoucename.js' etc --- zim.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/zim.cc b/zim.cc index 04a5df12..1b1c94f4 100644 --- a/zim.cc +++ b/zim.cc @@ -863,7 +863,7 @@ string ZimDictionary::convert( const string & in ) if( !url.isEmpty() && !url.startsWith( "//" ) && !url.startsWith( "http://" ) && !url.startsWith( "https://" ) ) { //<\\1 \\2src=\\3bres://%1/ - url.replace( RX::Zim::linkSpecialChar, "" ); + url.remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption)); replacedLink = QString( "<%1 %2 src=\"bres://%3/%4\"" ).arg( list[ 1 ], list[ 2 ], QString::fromStdString( getId() ), url ); } @@ -1520,8 +1520,8 @@ void ZimResourceRequest::run() sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name ) { - auto formatedName = QString::fromStdString(name).replace(RX::Zim::linkSpecialChar,""); - return new ZimResourceRequest( *this, formatedName.toStdString() ); +// auto formatedName = QString::fromStdString(name).replace(RX::Zim::linkSpecialChar,""); + return new ZimResourceRequest( *this, name ); } //} // anonymous namespace @@ -1693,10 +1693,10 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } else { - url.insert( url.begin(), '/' ); - url.insert( url.begin(), nameSpace ); - auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar,""); - indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n ); +// url.insert( url.begin(), '/' ); +// url.insert( url.begin(), nameSpace ); +// auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar," "); + indexedResources.addSingleWord( Utf8::decode( url ), n ); } } else @@ -1726,16 +1726,14 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } } else - if( nameSpace == 'X' ) + if( nameSpace == 'X' || nameSpace=='V' || nameSpace=='U'|| nameSpace=='W' ) { continue; } else { - url.insert( url.begin(), '/' ); - url.insert( url.begin(), nameSpace ); - auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar,""); - indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n ); +// auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar," "); + indexedResources.addSingleWord( Utf8::decode( url ), n ); } }