fixed read case sentive extesion and updated deprecated read to readUrl

Signed-off-by: Alisson Fabiano <afabiano@eshopworld.com>
This commit is contained in:
Alisson Fabiano
2022-10-26 15:26:21 +01:00
parent 7f20c4dad9
commit a0d6e94f93
2 changed files with 7 additions and 5 deletions
@@ -408,14 +408,15 @@ export class AzureDevOpsApi {
content: string;
}> {
const url = buildEncodedUrl(host, org, project, repo, 'README.md');
const response = await this.urlReader.read(url);
const response = await this.urlReader.readUrl(url);
const buffer = await response.buffer();
const content = await replaceReadme(
this.urlReader,
host,
org,
project,
repo,
response.toString(),
buffer.toString(),
);
return { url, content };
}
@@ -223,8 +223,9 @@ export async function replaceReadme(
const { label, path, ext } = extractPartsFromAsset(filePath);
const data = mime.lookup(ext);
const url = buildEncodedUrl(host, org, project, repo, path + ext);
const buffer = await urlReader.read(url);
const file = await buffer.toString('base64');
const response = await urlReader.readUrl(url);
const buffer = await response.buffer();
const file = buffer.toString('base64');
return content.replace(
filePath,
`[${label}](data:${data};base64,${file})`,
@@ -320,7 +321,7 @@ export function extractPartsFromAsset(content: string): {
ext: string;
} {
const regExp =
/\[(.*?)\]\((?!https?:\/\/)(.*?)(\.png|\.jpg|\.jpeg|\.gif|\.webp)(.*)\)/;
/\[(.*?)\]\((?!https?:\/\/)(.*?)(\.png|\.jpg|\.jpeg|\.gif|\.webp)(.*)\)/i;
const [_, label, path, ext] = regExp.exec(content) || [];
return {
ext,