File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
src/content/pages/problemset Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,15 @@ export function intercept(): void {
19
19
password ?: string ,
20
20
disbaleIntercept ?: boolean
21
21
) {
22
+ let pathname = url
23
+ try {
24
+ const urlObj = new URL ( url )
25
+ pathname = urlObj . pathname
26
+ } catch ( error ) { }
22
27
if (
23
28
! disbaleIntercept &&
24
29
method . toLocaleLowerCase ( ) === 'post' &&
25
- url === `/graphql/`
30
+ pathname === `/graphql/`
26
31
) {
27
32
const originalSend = this . send
28
33
@@ -115,6 +120,19 @@ export function intercept(): void {
115
120
} catch ( error ) {
116
121
//
117
122
}
123
+ } else if ( typeof str === 'string' ) {
124
+ try {
125
+ const body = JSON . parse ( str )
126
+ const sortOrder = body ?. variables ?. filters ?. sortOrder
127
+ if (
128
+ sortOrder &&
129
+ sortOrder !== 'DESCENDING' &&
130
+ sortOrder !== 'ASCENDING'
131
+ ) {
132
+ body . variables . filters . sortOrder = 'DESCENDING'
133
+ str = JSON . stringify ( body )
134
+ }
135
+ } catch ( error ) { }
118
136
}
119
137
return originalSend . call ( this , str )
120
138
}
You can’t perform that action at this time.
0 commit comments