Skip to content

Commit dd8ba8b

Browse files
authored
fix: can't sign in by cookie on leetcode-cn site (#55)
* fix: can't sign in by cookie on leetcode-cn site * Used const instead of let
1 parent cd5d4ef commit dd8ba8b

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Diff for: lib/plugins/leetcode.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,9 @@ plugin.login = function(user, cb) {
534534
};
535535

536536
function parseCookie(cookie, body, cb) {
537-
const isCN = config.app === 'leetcode.cn';
538537
const SessionPattern = /LEETCODE_SESSION=(.+?)(;|$)/;
539-
let csrfPattern;
540-
if (isCN) {
541-
csrfPattern = /name="csrfmiddlewaretoken" value="(.*?)"/;
542-
} else {
543-
csrfPattern = /csrftoken=(.+?)(;|$)/;
544-
}
545-
const reCsrfResult = csrfPattern.exec(isCN? body: cookie);
538+
const csrfPattern = /csrftoken=(.+?)(;|$)/;
539+
const reCsrfResult = csrfPattern.exec(cookie);
546540
const reSessionResult = SessionPattern.exec(cookie);
547541
if (reSessionResult === null || reCsrfResult === null) {
548542
return cb('invalid cookie?');

0 commit comments

Comments
 (0)