fix: when detecting format, first apply the dollar->newline hack
This commit is contained in:
parent
f890fc673f
commit
f8bb6e7ab7
1 changed files with 7 additions and 1 deletions
|
@ -46,6 +46,8 @@ function addPointsToTrack(trackInfo, body, format = null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectFormat(body) {
|
function detectFormat(body) {
|
||||||
|
body = replaceDollarNewlinesHack(body)
|
||||||
|
|
||||||
if (!body.length) {
|
if (!body.length) {
|
||||||
return 'invalid';
|
return 'invalid';
|
||||||
}
|
}
|
||||||
|
@ -53,7 +55,9 @@ function detectFormat(body) {
|
||||||
const firstLinebreakIndex = body.indexOf('\n');
|
const firstLinebreakIndex = body.indexOf('\n');
|
||||||
|
|
||||||
if (firstLinebreakIndex === -1) {
|
if (firstLinebreakIndex === -1) {
|
||||||
return 1;
|
// We need at least one linebreak in the whole file, to separate header and
|
||||||
|
// data. If the file contains no header, it is in valid.
|
||||||
|
return 'invalid'
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstLine = body.substring(0, firstLinebreakIndex);
|
const firstLine = body.substring(0, firstLinebreakIndex);
|
||||||
|
@ -63,6 +67,8 @@ function detectFormat(body) {
|
||||||
return Number(match[2]);
|
return Number(match[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we have no metadata line, but start immediately with a header, it is
|
||||||
|
// format version 1.
|
||||||
if (/^Date;Time/.test(firstLine)) {
|
if (/^Date;Time/.test(firstLine)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue