Skip to content

Commit

Permalink
fix(file): replaced backslash in path output of generate images API res
Browse files Browse the repository at this point in the history
Image save path in generateImages API result includes backslash on Windows. We need to replace
backslashes with slashes for the path output.

fix #64
  • Loading branch information
onderceylan committed Oct 31, 2019
1 parent 44db7df commit 4cf6912
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/helpers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const isHtmlFile = (file: string): boolean => {
return ['html', 'htm'].includes(getExtension(file));
};

const convertBackslashPathToSlashPath = (backSlashPath: string): string => {
return slash(backSlashPath);
};

const getAppDir = (): string => {
let appPath;
try {
Expand All @@ -50,7 +54,9 @@ const getImageSavePath = (
outputFolder: string,
ext: Extension,
): string => {
return path.join(outputFolder, `${imageName}.${ext}`);
return convertBackslashPathToSlashPath(
path.join(outputFolder, `${imageName}.${ext}`),
);
};

const fileUrl = (filePath: string): string => {
Expand Down Expand Up @@ -142,10 +148,6 @@ const writeFile = (filePath: string, data: string): Promise<void> => {
});
};

const convertBackslashPathToSlashPath = (backSlashPath: string): string => {
return slash(backSlashPath);
};

const getRelativeImagePath = (
outputFilePath: string,
imagePath: string,
Expand Down

0 comments on commit 4cf6912

Please sign in to comment.