@@ -135,9 +135,7 @@ export const useSubscribesStore = defineStore('subscribes', () => {
135135 }
136136
137137 const _doUpdateSub = async ( s : Subscription ) => {
138- const pattern =
139- / u p l o a d = ( - ? ) ( [ E + . \d ] + ) ; \s * d o w n l o a d = ( - ? ) ( [ E + . \d ] + ) ; \s * t o t a l = ( [ E + . \d ] + ) ; \s * e x p i r e = ( \d * ) /
140- let userInfo = 'upload=0; download=0; total=0; expire=0'
138+ const userInfo : Recordable = { }
141139 let body = ''
142140 let proxies : Record < string , any > [ ] = [ ]
143141
@@ -160,7 +158,12 @@ export const useSubscribesStore = defineStore('subscribes', () => {
160158 } ,
161159 } )
162160 Object . assign ( h , s . header . response )
163- h [ 'Subscription-Userinfo' ] && ( userInfo = h [ 'Subscription-Userinfo' ] as string )
161+ if ( h [ 'Subscription-Userinfo' ] ) {
162+ ; ( h [ 'Subscription-Userinfo' ] as string ) . split ( / \s * ; \s * / ) . forEach ( ( part ) => {
163+ const [ key , value ] = part . split ( '=' )
164+ userInfo [ key ] = parseInt ( value ) || 0
165+ } )
166+ }
164167 body = b
165168 }
166169
@@ -233,13 +236,10 @@ export const useSubscribesStore = defineStore('subscribes', () => {
233236 }
234237 }
235238
236- const match = userInfo . match ( pattern ) || [ 0 , 0 , 0 , 0 , 0 ]
237-
238- const [ , , upload = 0 , , download = 0 , total = 0 , expire = 0 ] = match
239- s . upload = Number ( upload )
240- s . download = Number ( download )
241- s . total = Number ( total )
242- s . expire = Number ( expire ) * 1000
239+ s . upload = userInfo . upload
240+ s . download = userInfo . download
241+ s . total = userInfo . total
242+ s . expire = userInfo . expire * 1000
243243 s . updateTime = Date . now ( )
244244 s . proxies = proxies . map ( ( { name, type, __id__ } ) => ( { id : __id__ , name, type } ) )
245245
0 commit comments