mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-28 11:41:26 +02:00
fix: fix anonymization of raw links
This commit is contained in:
@@ -218,7 +218,7 @@ export default class AnonymizedFile {
|
|||||||
res.header("Accept-Ranges", "none");
|
res.header("Accept-Ranges", "none");
|
||||||
try {
|
try {
|
||||||
const fileInfo = await storage.fileInfo(this.originalCachePath);
|
const fileInfo = await storage.fileInfo(this.originalCachePath);
|
||||||
if (fileInfo.size) {
|
if (!isTextFile(this.anonymizedPath) && fileInfo.size) {
|
||||||
res.header("Content-Length", fileInfo.size.toString());
|
res.header("Content-Length", fileInfo.size.toString());
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -79,6 +79,15 @@ export function anonymizeContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (repository.source instanceof GitHubBase) {
|
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(
|
content = content.replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`https://github.com/${
|
`https://github.com/${
|
||||||
|
|||||||
Reference in New Issue
Block a user