Skip to content

Commit

Permalink
matched common mobile subdomains to '.' in utils.js;
Browse files Browse the repository at this point in the history
added related test case
  • Loading branch information
Cay-Zhang committed Sep 18, 2020
1 parent 5e64472 commit 146d4ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions RSSBudTests/RSSBudTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,36 @@ class RSSBudTests: XCTestCase {
wait(for: [expectation], timeout: 3.0)
}

func testMobileSubdomains() {
RSSHub.Radar.rulesCenter.setRules(RSSHub.Radar.rulesCenter.bundledRules())

let expectation1 = XCTestExpectation(description: "Detect the feed from the url containing a mobile subdomain.")
let urlString1 = "https://m.zhaishuyuan.com/book/38082"
let url1 = URLComponents(autoPercentEncoding: urlString1)!

RSSHub.Radar.detecting(url: url1)
.sink { _ in

} receiveValue: { feeds in
XCTAssertEqual(feeds.count, 1, "Unexpected feed count.")
expectation1.fulfill()
}.store(in: &self.cancelBag)

let expectation2 = XCTestExpectation(description: "Detect the feed from the url containing a mobile subdomain.")
let urlString2 = "https://mobile.twitter.com/SwiftUILab"
let url2 = URLComponents(autoPercentEncoding: urlString2)!

RSSHub.Radar.detecting(url: url2)
.sink { _ in

} receiveValue: { feeds in
XCTAssertEqual(feeds.count, 3, "Unexpected feed count.")
expectation2.fulfill()
}.store(in: &self.cancelBag)

wait(for: [expectation1, expectation2], timeout: 6.0)
}

func testRSSHubRadarRulesConsistency() {
let expectation = XCTestExpectation(description: "Remote rules are equal to bundled rules.")

Expand Down
2 changes: 1 addition & 1 deletion Shared/RSSHub Radar/radar-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ var rules = ({
},
'zhaishuyuan.com': {
_name: '斋书苑',
www: [
'.': [
{
title: '最新章节',
docs: 'https://docs.rsshub.app/reading.html#zhai-shu-yuan',
Expand Down
2 changes: 1 addition & 1 deletion Shared/RSSHub Radar/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getPageRSSHub(data) {
if (rules[domain]) {
let rule = rules[domain][subdomain || '.'];
if (!rule) {
if (subdomain === 'www') {
if (subdomain === 'www' || subdomain === 'mobile' || subdomain === 'm') {
rule = rules[domain]['.'];
} else if (!subdomain) {
rule = rules[domain].www;
Expand Down

0 comments on commit 146d4ec

Please sign in to comment.