Skip to content

Commit

Permalink
fix: optimize code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuxia211 committed Dec 7, 2024
1 parent 03a6920 commit 7f1e735
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jwch.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ func (s *Student) NewRequest() *resty.Request {

func (s *Student) GetWithIdentifier(url string) (*html.Node, error) {
resp, err := s.NewRequest().SetHeader("Referer", constants.JwchReferer).SetQueryParam("id", s.Identifier).Get(url)
// 会话过期:会直接重定向,但我们禁用了重定向,所以会有error
if err != nil {
return nil, errno.CookieError
}

// 会话过期 TODO: 判断条件有点简陋
// 还有一种情况是 id 或 cookie 缺失或者解析错误 TODO: 判断条件有点简陋
if strings.Contains(string(resp.Body()), "重新登录") {
return nil, errno.CookieError
}
Expand All @@ -95,12 +96,12 @@ func (s *Student) PostWithIdentifier(url string, formData map[string]string) (*h
resp, err := s.NewRequest().SetHeader("Referer", constants.JwchReferer).SetQueryParam("id", s.Identifier).SetFormData(formData).Post(url)

s.NewRequest().EnableTrace()

// 会话过期:会直接重定向,但我们禁用了重定向,所以会有error
if err != nil {
return nil, errno.CookieError.WithErr(err)
}

// Identifier缺失 TODO: 判断条件有点简陋
// id 或 cookie 缺失或者解析错误 TODO: 判断条件有点简陋
if strings.Contains(string(resp.Body()), "处理URL失败") {
return nil, errno.CookieError
}
Expand Down

0 comments on commit 7f1e735

Please sign in to comment.