mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: mem limiter for invalid ranges
This commit is contained in:
+7
-5
@@ -9,12 +9,14 @@ export class Limiter {
|
||||
this.limit = limit
|
||||
}
|
||||
use (count: number) {
|
||||
count = +count || 0
|
||||
assert(this.base + count <= this.limit, this.message)
|
||||
this.base += count
|
||||
if (+count > 0) {
|
||||
assert(this.base + +count <= this.limit, this.message)
|
||||
this.base += +count
|
||||
}
|
||||
}
|
||||
check (count: number) {
|
||||
count = +count || 0
|
||||
assert(count <= this.limit, this.message)
|
||||
if (+count > 0) {
|
||||
assert(+count <= this.limit, this.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user