1
0
mirror of https://github.com/cwchristerw/bokxin-ip synced 2024-11-21 23:10:26 +00:00

Better end part handling (#2)

* Better end part handling

* Changes

* Fixing typo
This commit is contained in:
Christer Warén 2020-01-26 21:24:38 +02:00 committed by Juho Salli
parent a02c669cc8
commit 3b6e97c5b8

View File

@ -12,6 +12,8 @@ const IndexPage = () => {
// console.log({ osat }) // console.log({ osat })
setIp("") setIp("")
if (osat.loppu === "" || osat.loppu.length !== 4) return 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 ekanumero = ""
let loppu = osat.loppu let loppu = osat.loppu
@ -26,10 +28,10 @@ const IndexPage = () => {
} }
let loppuosa = "" let loppuosa = ""
for (let i of loppu.slice(1)) { loppuosa = loppu.slice(1)
if (i !== "0") {
loppuosa += i while(loppuosa.charAt(0) === '0'){
} loppuosa = loppuosa.substr(1)
} }
setIp(`10.22${ekanumero}.${loppuosa}.x`) setIp(`10.22${ekanumero}.${loppuosa}.x`)