fix: fix anonymization of raw links

This commit is contained in:
tdurieux
2023-05-02 16:00:47 +02:00
parent 53ea31008a
commit abddf10c11
2 changed files with 10 additions and 1 deletions

View File

@@ -218,7 +218,7 @@ export default class AnonymizedFile {
res.header("Accept-Ranges", "none");
try {
const fileInfo = await storage.fileInfo(this.originalCachePath);
if (fileInfo.size) {
if (!isTextFile(this.anonymizedPath) && fileInfo.size) {
res.header("Content-Length", fileInfo.size.toString());
}
} catch (error) {

View File

@@ -79,6 +79,15 @@ export function anonymizeContent(
}
if (repository.source instanceof GitHubBase) {
content = content.replace(
new RegExp(
`https://raw.githubusercontent.com/${
repository.source.githubRepository.fullName
}/${repository.source.branch?.name || "main"}\\b`,
"gi"
),
`https://${config.APP_HOSTNAME}/r/${repository.repoId}`
);
content = content.replace(
new RegExp(
`https://github.com/${