mirror of
https://github.com/jsbin/jsbin.git
synced 2026-01-25 15:38:56 +00:00
Remove modulus from percentage calculation
Instead take the last part of ip, divide by 256 to get percentage and compare to percentage passed in.
This commit is contained in:
parent
a886652280
commit
846010ed6e
@ -59,13 +59,8 @@ function ipAsNum(req) {
|
||||
}
|
||||
|
||||
function percentage(n, req) {
|
||||
var mod = parseInt(100 / n, 10); // ensures whole number
|
||||
if (mod === 0) {
|
||||
mod = 1;
|
||||
}
|
||||
var ip = ipAsNum(req);
|
||||
|
||||
return ip % mod === 0;
|
||||
return (ip / 256) <= (n / 100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user