fr
This commit is contained in:
@@ -174,7 +174,8 @@ export async function POST(req: NextRequest) {
|
||||
console.log("🔍 Appel à Presidio Analyzer...");
|
||||
|
||||
// ✅ Définir l'URL AVANT de l'utiliser
|
||||
const presidioAnalyzerUrl = "http://localhost:5001/analyze";
|
||||
const presidioAnalyzerUrl =
|
||||
"http://analyzer.151.80.20.211.sslip.io/analyze";
|
||||
|
||||
try {
|
||||
const analyzeResponse = await fetch(presidioAnalyzerUrl, {
|
||||
@@ -211,7 +212,8 @@ export async function POST(req: NextRequest) {
|
||||
};
|
||||
|
||||
console.log("🔍 Appel à Presidio Anonymizer...");
|
||||
const presidioAnonymizerUrl = "http://localhost:5001/anonymize";
|
||||
const presidioAnonymizerUrl =
|
||||
"http://analyzer.151.80.20.211.sslip.io/anonymize";
|
||||
|
||||
const anonymizeResponse = await fetch(presidioAnonymizerUrl, {
|
||||
method: "POST",
|
||||
@@ -255,10 +257,15 @@ export async function POST(req: NextRequest) {
|
||||
let anonymizedIndex = 0;
|
||||
|
||||
// Trier les résultats par position
|
||||
const sortedResults = [...analyzerResults].sort((a, b) => a.start - b.start);
|
||||
const sortedResults = [...analyzerResults].sort(
|
||||
(a, b) => a.start - b.start
|
||||
);
|
||||
|
||||
for (const result of sortedResults) {
|
||||
const originalValue = originalText.substring(result.start, result.end);
|
||||
const originalValue = originalText.substring(
|
||||
result.start,
|
||||
result.end
|
||||
);
|
||||
|
||||
// Avancer jusqu'à la position de l'entité dans le texte original
|
||||
while (originalIndex < result.start) {
|
||||
@@ -268,15 +275,21 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
// Maintenant on est au début de l'entité
|
||||
// Dans le texte anonymisé, on doit avoir un remplacement qui commence par '['
|
||||
if (anonymizedText[anonymizedIndex] === '[') {
|
||||
if (anonymizedText[anonymizedIndex] === "[") {
|
||||
// Trouver la fin du remplacement (le ']')
|
||||
let endBracket = anonymizedIndex;
|
||||
while (endBracket < anonymizedText.length && anonymizedText[endBracket] !== ']') {
|
||||
while (
|
||||
endBracket < anonymizedText.length &&
|
||||
anonymizedText[endBracket] !== "]"
|
||||
) {
|
||||
endBracket++;
|
||||
}
|
||||
endBracket++; // Inclure le ']'
|
||||
|
||||
const replacementValue = anonymizedText.substring(anonymizedIndex, endBracket);
|
||||
const replacementValue = anonymizedText.substring(
|
||||
anonymizedIndex,
|
||||
endBracket
|
||||
);
|
||||
replacementMap[originalValue] = replacementValue;
|
||||
|
||||
// Avancer les index
|
||||
@@ -285,7 +298,7 @@ export async function POST(req: NextRequest) {
|
||||
} else {
|
||||
// Si pas de '[', avancer normalement
|
||||
originalIndex = result.end;
|
||||
anonymizedIndex += (result.end - result.start);
|
||||
anonymizedIndex += result.end - result.start;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user