@@ -15,6 +15,7 @@ static const char * const KEY_LINK_STR_END = "link_str_end";
1515static const char * const KEY_LINK_PATTERN = " link_pattern" ;
1616static const char * const KEY_CONTENT_PATTERN = " content_pattern" ;
1717static const char * const KEY_INTERVAL = " interval" ;
18+ static const char * const KEY_LINKTYPE = " link_type" ;
1819static const char * const INDEX_PAGE_FNAME = " ./index.html" ;
1920static const char * const BOOK_PAGE_FNAME = " ./page.html" ;
2021static const char * const BOOK_SAVE_FNAME = " ./out.txt" ;
@@ -87,12 +88,25 @@ bool Worker::requestBookPages(const QString &urlStr)
8788 QString title = match.captured (2 );
8889 QString linkAddr;
8990 const QUrl &url = m_siteInfo.m_url ;
90- if (!urlStr.endsWith (' /' )) {
91- // there is a file name exist
92- linkAddr = url.scheme () + " ://" + url.host () + sublink;
93- } else {
94- linkAddr = url.toString () + sublink;
91+ switch (m_siteInfo.m_linkType ) {
92+ case 0 : {
93+ linkAddr = url.scheme () + " ://" + url.host () + sublink;
94+ break ;
95+ }
96+ case 1 : {
97+ linkAddr = url.toString () + sublink;
98+ break ;
99+ }
100+ case 2 : {
101+ QString strUrl = url.toString ();
102+ int pos = strUrl.lastIndexOf (' /' );
103+ linkAddr = strUrl.left (pos) + " /" + sublink;
104+ break ;
105+ }
106+ default :
107+ break ;
95108 }
109+
96110 m_pageInfos.append (PageInfo (linkAddr, title));
97111 // qDebug() << link << title;
98112 }
@@ -185,6 +199,8 @@ bool Worker::loadSiteConfigs(const QUrl &url)
185199 m_siteInfo.m_linkPattern = cfg->value (KEY_LINK_PATTERN).toString ();
186200 m_siteInfo.m_bookPattern = cfg->value (KEY_CONTENT_PATTERN).toString ();
187201 m_siteInfo.m_interval = cfg->value (KEY_INTERVAL, 0 ).toInt ();
202+ m_siteInfo.m_linkType = cfg->value (KEY_LINKTYPE, 0 ).toInt ();
203+
188204 cfg->endGroup ();
189205
190206 isSupport = true ;
0 commit comments