mirror of
https://github.com/cwchristerw/bokxin-ip
synced 2024-11-21 20:00:26 +00:00
Better end part handling (#2)
* Better end part handling * Changes * Fixing typo
This commit is contained in:
parent
a02c669cc8
commit
3b6e97c5b8
@ -12,6 +12,8 @@ const IndexPage = () => {
|
||||
// console.log({ osat })
|
||||
setIp("")
|
||||
if (osat.loppu === "" || osat.loppu.length !== 4) return
|
||||
if (osat.loppu.slice(0, 1) !== "2" && osat.loppu.slice(0, 1) !== "3") return
|
||||
if (parseInt(osat.loppu.slice(1)) >= 255 || parseInt(osat.loppu.slice(1)) === 0 || isNaN(parseInt(osat.loppu.slice(1)))) return
|
||||
|
||||
let ekanumero = ""
|
||||
let loppu = osat.loppu
|
||||
@ -26,10 +28,10 @@ const IndexPage = () => {
|
||||
}
|
||||
|
||||
let loppuosa = ""
|
||||
for (let i of loppu.slice(1)) {
|
||||
if (i !== "0") {
|
||||
loppuosa += i
|
||||
}
|
||||
loppuosa = loppu.slice(1)
|
||||
|
||||
while(loppuosa.charAt(0) === '0'){
|
||||
loppuosa = loppuosa.substr(1)
|
||||
}
|
||||
|
||||
setIp(`10.22${ekanumero}.${loppuosa}.x`)
|
||||
|
Loading…
Reference in New Issue
Block a user