Merge pull request #112 from mutantmonkey/issue_111
Fix max expiry when provided expiry is 0
This commit is contained in:
commit
e588d78299
|
@ -450,7 +450,9 @@ func TestPostJSONUploadMaxExpiry(t *testing.T) {
|
||||||
mux := setup()
|
mux := setup()
|
||||||
Config.maxExpiry = 300
|
Config.maxExpiry = 300
|
||||||
|
|
||||||
testExpiries := []string{"86400", "-150"}
|
// include 0 to test edge case
|
||||||
|
// https://github.com/andreimarcu/linx-server/issues/111
|
||||||
|
testExpiries := []string{"86400", "-150", "0"}
|
||||||
for _, expiry := range testExpiries {
|
for _, expiry := range testExpiries {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ func parseExpiry(expStr string) time.Duration {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Duration(Config.maxExpiry) * time.Second
|
return time.Duration(Config.maxExpiry) * time.Second
|
||||||
} else {
|
} else {
|
||||||
if Config.maxExpiry > 0 && expiry > Config.maxExpiry {
|
if Config.maxExpiry > 0 && (expiry > Config.maxExpiry || expiry == 0) {
|
||||||
expiry = Config.maxExpiry
|
expiry = Config.maxExpiry
|
||||||
}
|
}
|
||||||
return time.Duration(expiry) * time.Second
|
return time.Duration(expiry) * time.Second
|
||||||
|
|
Loading…
Reference in New Issue