mirror of
https://github.com/Koenkk/zigbee-OTA.git
synced 2026-09-25 14:01:28 +00:00
Fix url encoding (#679)
This commit is contained in:
+1
-1
@@ -78,7 +78,7 @@ export function getOutDir(folderName: string, basePath: string = BASE_IMAGES_DIR
|
||||
}
|
||||
|
||||
export function getRepoFirmwareFileUrl(folderName: string, fileName: string, basePath: string = BASE_IMAGES_DIR): string {
|
||||
return BASE_REPO_URL + path.posix.join(REPO_BRANCH, basePath, folderName, fileName);
|
||||
return BASE_REPO_URL + path.posix.join(REPO_BRANCH, basePath, folderName, encodeURIComponent(fileName));
|
||||
}
|
||||
|
||||
export function writeManifest(fileName: string, firmwareList: RepoImageMeta[]): void {
|
||||
|
||||
@@ -101,8 +101,7 @@ async function download3rdParties(
|
||||
continue;
|
||||
}
|
||||
|
||||
// reverse add.js logic
|
||||
const fileName = unescape(meta.url.split('/').pop()!);
|
||||
const fileName = decodeURIComponent(meta.url.split('/').pop()!);
|
||||
const outDirName = outDirFinder(meta);
|
||||
|
||||
if (outDirName) {
|
||||
@@ -245,13 +244,9 @@ function checkImagesAgainstManifests(github: Octokit, core: typeof CoreApi, cont
|
||||
|
||||
for (const fileName of readdirSync(subfolderPath)) {
|
||||
const firmwareFilePath = path.join(subfolderPath, fileName);
|
||||
const fileRelUrl = path.posix.join(imagesDir, subfolderName, fileName);
|
||||
// previous add.js used escape() for url property
|
||||
const escFileRelUrl = escape(fileRelUrl);
|
||||
const fileRelUrl = path.posix.join(imagesDir, subfolderName, encodeURIComponent(fileName));
|
||||
// take local images only
|
||||
const inManifest = manifest.filter(
|
||||
(m) => m.url.startsWith(BASE_REPO_URL + REPO_BRANCH) && (m.url.endsWith(fileRelUrl) || m.url.endsWith(escFileRelUrl)),
|
||||
);
|
||||
const inManifest = manifest.filter((m) => m.url.startsWith(BASE_REPO_URL + REPO_BRANCH) && m.url.endsWith(fileRelUrl));
|
||||
|
||||
if (inManifest.length === 0) {
|
||||
core.warning(`Not found in base manifest: ${firmwareFilePath}.`);
|
||||
@@ -396,3 +391,13 @@ export async function reProcessAllImages(
|
||||
|
||||
checkImagesAgainstManifests(github, core, context, removeNotInManifest);
|
||||
}
|
||||
|
||||
// To run locally uncomment below and run with `npx tsx src/ghw_reprocess_all_images.ts`
|
||||
// const core = {
|
||||
// info: (msg) => console.log(msg),
|
||||
// warning: (msg) => console.log(msg),
|
||||
// error: (msg) => console.error(msg),
|
||||
// startGroup: () => {},
|
||||
// endGroup: () => {},
|
||||
// }
|
||||
// checkImagesAgainstManifests(null, core, null, false);
|
||||
|
||||
Reference in New Issue
Block a user