File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1
1
import _ from "lodash"
2
2
3
+ import MD5 from "md5.js"
3
4
import { getConfig } from "./config"
4
5
import { defaultRules } from "./radar-rules"
5
6
import type { Rules } from "./types"
@@ -40,10 +41,18 @@ export function getRemoteRules() {
40
41
return new Promise < string > ( async ( resolve , reject ) => {
41
42
const config = await getConfig ( )
42
43
try {
43
- const res = await fetch ( getRadarRulesUrl ( config . rsshubDomain ) )
44
+ let url = getRadarRulesUrl ( config . rsshubDomain )
45
+
46
+ if ( config . rsshubAccessControl . accessKey ) {
47
+ const path = new URL ( url ) . pathname
48
+ const code = new MD5 ( ) . update ( path + config . rsshubAccessControl . accessKey ) . digest ( "hex" )
49
+ url = `${ url } ?code=${ code } `
50
+ }
51
+
52
+ const res = await fetch ( url )
44
53
resolve ( res . text ( ) )
45
54
} catch ( error ) {
46
55
reject ( error )
47
56
}
48
57
} )
49
- }
58
+ }
Original file line number Diff line number Diff line change @@ -35,9 +35,10 @@ function RSSItem({
35
35
let url = item . url . replace (
36
36
"{rsshubDomain}" ,
37
37
config . rsshubDomain . replace ( / \/ $ / , "" ) ,
38
- )
38
+ ) . replace ( / \/ $ / , "" )
39
+
39
40
if ( type === "currentPageRSSHub" && config . rsshubAccessControl . accessKey ) {
40
- url = `${ url } ?code=${ new MD5 ( ) . update ( item . path + config . rsshubAccessControl . accessKey ) . digest ( "hex" ) } `
41
+ url = `${ url } ?code=${ new MD5 ( ) . update ( item . path . replace ( / \/ $ / , "" ) + config . rsshubAccessControl . accessKey ) . digest ( "hex" ) } `
41
42
}
42
43
if ( type === "currentPageRSSHub" ) {
43
44
item . title = item . title . replace (
You can’t perform that action at this time.
0 commit comments