File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 "@radix-ui/react-slot" : " ^1.1.2" ,
2929 "@radix-ui/react-switch" : " ^1.1.3" ,
3030 "async-lock" : " ^1.4.1" ,
31+ "blueimp-md5" : " ^2.19.0" ,
3132 "class-variance-authority" : " ^0.7.1" ,
3233 "clsx" : " ^2.1.1" ,
3334 "foxact" : " ^0.2.44" ,
3435 "he" : " 1.2.0" ,
3536 "lodash" : " ^4.17.21" ,
3637 "lucide-react" : " ^0.475.0" ,
37- "md5.js" : " ^1.3.5" ,
3838 "react" : " 18.3.1" ,
3939 "react-dom" : " 18.3.1" ,
4040 "react-hot-toast" : " ^2.5.1" ,
Original file line number Diff line number Diff line change 1+ declare module "blueimp-md5" {
2+ export default function md5 ( value : string ) : string
3+ }
Original file line number Diff line number Diff line change 1+ import md5 from "blueimp-md5"
12import _ from "lodash"
2- import MD5 from "md5.js"
33
44import { getConfig } from "./config"
55import { defaultRules } from "./radar-rules"
@@ -47,12 +47,14 @@ export async function getRemoteRules() {
4747 const config = await getConfig ( )
4848 let url = getRadarRulesUrl ( config . rsshubDomain )
4949
50- if ( config . rsshubAccessControl . accessKey ) {
51- const path = new URL ( url ) . pathname
52- const code = new MD5 ( )
53- . update ( path + config . rsshubAccessControl . accessKey )
54- . digest ( "hex" )
55- url = `${ url } ?code=${ code } `
50+ if ( config . rsshubAccessControl . accessKey ?. trim ( ) ) {
51+ const accessKey = config . rsshubAccessControl . accessKey . trim ( )
52+
53+ if ( config . rsshubAccessControl . accessKeyType === "key" ) {
54+ url = `${ url } ?key=${ encodeURIComponent ( accessKey ) } `
55+ } else {
56+ url = `${ url } ?code=${ md5 ( new URL ( url ) . pathname + accessKey ) } `
57+ }
5658 }
5759
5860 const res = await fetch ( url )
Original file line number Diff line number Diff line change @@ -44,5 +44,5 @@ export async function fetchRSSContent(url: string) {
4444}
4545
4646export function getRadarRulesUrl ( rsshubDomain : string ) {
47- return `${ rsshubDomain } /api/radar/rules`
47+ return `${ rsshubDomain . replace ( / \/ + $ / , "" ) } /api/radar/rules`
4848}
Original file line number Diff line number Diff line change 1- import MD5 from "md5.js "
1+ import md5 from "blueimp- md5"
22import { useEffect , useState } from "react"
33import { useCopyToClipboard } from "usehooks-ts"
44
@@ -43,10 +43,10 @@ function RSSItem({
4343 if ( config . rsshubAccessControl . accessKeyType === "key" ) {
4444 urlObj . searchParams . append ( "key" , config . rsshubAccessControl . accessKey )
4545 } else {
46- const md5 = new MD5 ( )
47- . update ( urlObj . pathname + config . rsshubAccessControl . accessKey )
48- . digest ( "hex" )
49- urlObj . searchParams . append ( "code" , md5 )
46+ urlObj . searchParams . append (
47+ "code" ,
48+ md5 ( urlObj . pathname + config . rsshubAccessControl . accessKey ) ,
49+ )
5050 }
5151
5252 url = urlObj . toString ( )
You can’t perform that action at this time.
0 commit comments