Skip to content

Commit 997dddd

Browse files
committed
move market version tokens outside of func
1 parent 2095074 commit 997dddd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/getLatestVersion.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,24 @@ function getStoreUrl() {
5050
});
5151
}
5252

53+
const MARKETVERSION_STARTTOKEN = "softwareVersion\">";
54+
const MARKETVERSION_STARTTOKEN_LENGTH = MARKETVERSION_STARTTOKEN.length;
55+
const MARKETVERSION_ENDTOKEN = "<";
5356
function getLatestVersionFromUrl(url, fetchOptions) {
5457
return fetch(url, fetchOptions)
5558
.then(res => {
5659
return res.text();
5760
})
5861
.then((text) => {
59-
const startToken = "softwareVersion\">";
60-
const endToken = "<";
61-
62-
const indexStart = text.indexOf(startToken);
62+
const indexStart = text.indexOf(MARKETVERSION_STARTTOKEN);
6363
if (indexStart === -1) {
6464
latestVersion = text.trim();
6565
return Promise.resolve(latestVersion);
6666
}
6767

68-
text = text.substr(indexStart + startToken.length);
68+
text = text.substr(indexStart + MARKETVERSION_STARTTOKEN_LENGTH);
6969

70-
const indexEnd = text.indexOf(endToken);
70+
const indexEnd = text.indexOf(MARKETVERSION_ENDTOKEN);
7171
if (indexEnd === -1) {
7272
return Promise.reject("Parse error.");
7373
}

0 commit comments

Comments
 (0)