Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Fix regex inside sanitizeVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
notOsteen committed May 11, 2023
1 parent 0554a25 commit 06f245c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions wsEvents/getAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const sanitizeVersion = (ver) => {
while (ver.match(/\./g).length > 2) ver = ver.replace(/.([^.]*)$/, '$1');

return ver
.replace(/\.0(\d+)/gi, '.$1') // because apparently x.0y.z (ex. 5.09.51) isn't a valid version
.replace(/^(\d+)\.(\d+)$/gi, '$1.$2.0'); // nor are versions without a patch (ex. 2.3)
.replace(/\.0+(\d+)/g, '.$1') // replace leading zeroes with a single period
.replace(/^(\d+)\.(\d+)$/g, '$1.$2.0'); // add trailing ".0" if needed

};

/**
Expand Down Expand Up @@ -85,9 +86,8 @@ async function installRecommendedStock(ws, dId) {
return ws.send(
JSON.stringify({
event: 'error',
error: `An error occured while trying to install the stock app${
dId !== 'CURRENT_DEVICE' ? ` for device ID ${dId}` : ''
}.\nPlease install the recommended version manually and run Builder again.`
error: `An error occured while trying to install the stock app${dId !== 'CURRENT_DEVICE' ? ` for device ID ${dId}` : ''
}.\nPlease install the recommended version manually and run Builder again.`
})
);
}
Expand Down Expand Up @@ -125,8 +125,7 @@ async function downloadApp(ws, message) {
*/
module.exports = async function getAppVersion(ws, message) {
let versionsList = await getPage(
`${APKMIRROR_UPLOAD_BASE(message.page || 1)}${
global.jarNames.selectedApp.link.split('/')[3]
`${APKMIRROR_UPLOAD_BASE(message.page || 1)}${global.jarNames.selectedApp.link.split('/')[3]
}`
);

Expand Down

0 comments on commit 06f245c

Please sign in to comment.