Skip to content

Commit

Permalink
fix build test
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Jul 21, 2023
1 parent de20957 commit 1040830
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ratelimit_var.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"strings"
"time"
"unicode"

stringsutil "github.com/projectdiscovery/utils/strings"
timeutil "github.com/projectdiscovery/utils/time"
Expand Down Expand Up @@ -147,8 +148,17 @@ func parseRateLimit(s string) (RateLimit, error) {
if err != nil {
return RateLimit{}, errors.New("parse error: " + err.Error())
}
timeValue := sArr[1]
if len(timeValue) > 0 {
// check if time is given ex: 1s
// if given value is just s (add prefix 1)
firstChar := timeValue[0]
if !unicode.IsDigit(rune(firstChar)) {
timeValue = "1" + timeValue
}
}

duration, err := timeutil.ParseDuration(sArr[1])
duration, err := timeutil.ParseDuration(timeValue)
if err != nil {
return RateLimit{}, errors.New("parse error: " + err.Error())
}
Expand Down

0 comments on commit 1040830

Please sign in to comment.