From 2629949b669c6e14397d6a6d4dd35ef9df9451c4 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 18 Oct 2023 15:15:22 +0200 Subject: [PATCH] fix : URI_DETECTOR regex --- .../convert/confluence/ReferenceProvider.kt | 16 ++++++++++--- .../confluence/ReferenceProviderImplTest.kt | 23 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/convert/src/main/kotlin/com/github/zeldigas/text2confl/convert/confluence/ReferenceProvider.kt b/convert/src/main/kotlin/com/github/zeldigas/text2confl/convert/confluence/ReferenceProvider.kt index 1bb5e314..80e92b87 100644 --- a/convert/src/main/kotlin/com/github/zeldigas/text2confl/convert/confluence/ReferenceProvider.kt +++ b/convert/src/main/kotlin/com/github/zeldigas/text2confl/convert/confluence/ReferenceProvider.kt @@ -2,8 +2,11 @@ package com.github.zeldigas.text2confl.convert.confluence import com.github.zeldigas.text2confl.convert.PageHeader import io.github.oshai.kotlinlogging.KotlinLogging +import java.net.URL import java.nio.file.InvalidPathException import java.nio.file.Path +import java.util.regex.Matcher +import java.util.regex.Pattern import kotlin.io.path.relativeTo interface ReferenceProvider { @@ -41,16 +44,23 @@ class ReferenceProviderImpl(private val basePath: Path, documents: Map path.relativeTo(basePath).normalize() to header }.toMap() override fun resolveReference(source: Path, refTo: String): Reference? { - if (URI_DETECTOR.matches(refTo)) return null + if (refTo.startsWith(MAILTO_DETECTOR)) return null + if (isValid(refTo)) return null if (refTo.startsWith("#")) return Anchor(refTo.substring(1)) val parts = refTo.split("#", limit = 2) @@ -62,7 +72,7 @@ class ReferenceProviderImpl(private val basePath: Path, documents: Map