mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
code style, refactor removal of trailing zeroes
This commit is contained in:
parent
ca6e5a0d54
commit
cee3a78d8e
1 changed files with 8 additions and 10 deletions
|
@ -26,15 +26,13 @@ const transformReqBody = (body) => {
|
||||||
const parseLocation = (profile, l, lines) => {
|
const parseLocation = (profile, l, lines) => {
|
||||||
const res = _parseLocation(profile, l, lines)
|
const res = _parseLocation(profile, l, lines)
|
||||||
// weird fix for empty lines, e.g. IC/EC at Flensburg Hbf
|
// weird fix for empty lines, e.g. IC/EC at Flensburg Hbf
|
||||||
if(res.lines){
|
if (res.lines) {
|
||||||
res.lines = res.lines.filter(x => x.id && x.name)
|
res.lines = res.lines.filter(x => x.id && x.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing zeroes, todo
|
// remove trailing zeroes, todo
|
||||||
if(res.id && res.id.length > 2){
|
if (res.id && res.id.length > 0) {
|
||||||
while(res.id.slice(0, 1) === '0'){
|
res.id = res.id.replace(/^0+/, '')
|
||||||
res.id = res.id.slice(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
@ -73,10 +71,10 @@ const createParseJourney = (profile, stations, lines, remarks) => {
|
||||||
) {
|
) {
|
||||||
res.tickets = []
|
res.tickets = []
|
||||||
|
|
||||||
for(let t of j.trfRes.fareSetL){
|
for (let t of j.trfRes.fareSetL) {
|
||||||
const tariff = t.desc
|
const tariff = t.desc
|
||||||
if(!tariff || !Array.isArray(t.fareL)) continue
|
if (!tariff || !Array.isArray(t.fareL)) continue
|
||||||
for(let v of t.fareL){
|
for (let v of t.fareL) {
|
||||||
const variant = v.name
|
const variant = v.name
|
||||||
if(!variant) continue
|
if(!variant) continue
|
||||||
const ticket = {
|
const ticket = {
|
||||||
|
@ -84,11 +82,11 @@ const createParseJourney = (profile, stations, lines, remarks) => {
|
||||||
tariff,
|
tariff,
|
||||||
variant
|
variant
|
||||||
}
|
}
|
||||||
if(v.prc && Number.isInteger(v.prc) && v.cur){
|
if (v.prc && Number.isInteger(v.prc) && v.cur) {
|
||||||
ticket.amount = v.prc/100
|
ticket.amount = v.prc/100
|
||||||
ticket.currency = v.cur
|
ticket.currency = v.cur
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
ticket.amount = null
|
ticket.amount = null
|
||||||
ticket.hint = 'No pricing information available.'
|
ticket.hint = 'No pricing information available.'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue