diff --git a/idea-multimarkdown.iml b/idea-multimarkdown.iml
index ebc32a8d..37269bde 100644
--- a/idea-multimarkdown.iml
+++ b/idea-multimarkdown.iml
@@ -12,8 +12,8 @@
-
-
+
+
diff --git a/src/main/java/com/vladsch/idea/multimarkdown/util/GitHubLinkResolver.kt b/src/main/java/com/vladsch/idea/multimarkdown/util/GitHubLinkResolver.kt
index 097513ae..8dd9e4ec 100644
--- a/src/main/java/com/vladsch/idea/multimarkdown/util/GitHubLinkResolver.kt
+++ b/src/main/java/com/vladsch/idea/multimarkdown/util/GitHubLinkResolver.kt
@@ -27,11 +27,13 @@ import com.intellij.util.Processor
import com.intellij.util.indexing.FileBasedIndex
import com.intellij.util.indexing.FileBasedIndexImpl
import com.vladsch.idea.multimarkdown.MultiMarkdownPlugin
+import org.apache.log4j.Logger
import java.util.*
import kotlin.text.RegexOption
class GitHubLinkResolver(projectResolver: LinkResolver.ProjectResolver, containingFile: FileRef, branchOrTag: String? = null) : LinkResolver(projectResolver, containingFile, branchOrTag) {
+ private val logger = Logger.getLogger(GitHubLinkResolver::class.java)
companion object {
@JvmStatic @JvmField val GITHUB_BLOB_NAME = "blob"
@@ -211,7 +213,7 @@ class GitHubLinkResolver(projectResolver: LinkResolver.ProjectResolver, containi
} else {
// URL only, we need to convert to URI file:// type
if (wantLocal(options) && wantOnlyURI(options)) return LinkRef(containingFile, "file://" + LinkRef.urlEncode(targetRef.filePath), null, targetRef as FileRef?)
-// if (wantLocal(options) && wantOnlyURI(options)) return LinkRef(containingFile, "file://" + targetRef.filePath, null, targetRef as FileRef?)
+ // if (wantLocal(options) && wantOnlyURI(options)) return LinkRef(containingFile, "file://" + targetRef.filePath, null, targetRef as FileRef?)
}
} else {
// local, remote or URL
@@ -341,7 +343,6 @@ class GitHubLinkResolver(projectResolver: LinkResolver.ProjectResolver, containi
}
}
- val exactFileRefMatches = HashSet()
val rawWikiFileRefMatches = HashSet()
// now we need to weed out the matches that will not work, unless this is a loose match
@@ -361,7 +362,6 @@ class GitHubLinkResolver(projectResolver: LinkResolver.ProjectResolver, containi
if (fileOrAnchorMatch != null) {
for (fileRef in matches) {
if (fileRef is FileRef && fileRef.filePath.matches(fileOrAnchorMatch)) {
- exactFileRefMatches.add(fileRef)
rawWikiFileRefMatches.add(fileRef)
if (fileRef.isUnderWikiDir) fileRef.isRawFile = true
}
@@ -378,11 +378,8 @@ class GitHubLinkResolver(projectResolver: LinkResolver.ProjectResolver, containi
if (fileMatch != null) {
for (fileRef in matches) {
if (fileRef is FileRef) {
- val exactMatch = fileRef.filePath.matches(fileMatch)
- if (exactMatch) exactFileRefMatches.add(fileRef)
-
// it will be raw access if it is under the wiki directory and has a 'real' extension
- if (!fileRef.isWikiPageExt || exactMatch) {
+ if (!fileRef.isWikiPageExt || fileRef.filePath.matches(fileMatch)) {
rawWikiFileRefMatches.add(fileRef)
if (fileRef.isUnderWikiDir) fileRef.isRawFile = true
}
@@ -395,7 +392,6 @@ class GitHubLinkResolver(projectResolver: LinkResolver.ProjectResolver, containi
// these are already set for raw if taken from the raw/ access URL and all are exact matches
for (fileRef in matches) {
if (fileRef is FileRef) {
- exactFileRefMatches.add(fileRef)
rawWikiFileRefMatches.add(fileRef)
if (fileRef.isUnderWikiDir) fileRef.isRawFile = true
}
diff --git a/src/test/java/com/vladsch/idea/multimarkdown/util/MarkdownTestData.kt b/src/test/java/com/vladsch/idea/multimarkdown/util/MarkdownTestData.kt
index c0ca5713..6dfccd60 100644
--- a/src/test/java/com/vladsch/idea/multimarkdown/util/MarkdownTestData.kt
+++ b/src/test/java/com/vladsch/idea/multimarkdown/util/MarkdownTestData.kt
@@ -176,13 +176,11 @@ object MarkdownTestData : LinkResolver.ProjectResolver {
}
fun List.asFilePaths(): List {
- val result = this.map { it.filePath }
- return result
+ return this.map { it.filePath }
}
fun List.asURI(): List {
- val result = this.map { "file://" + it }
- return result
+ return this.map { "file://" + it.replace(" ", "%20").replace("#", "%23") }
}
fun List.with(list: List): List {
@@ -222,10 +220,6 @@ fun List.asRemoteUriType(branchOrTag: String? = null, gitHubLink: String
return result
}
-fun List.asLocalURI(branchOrTag: String? = null): List {
- return this.map { "file://" + it }
-}
-
val EMPTY_LIST = arrayListOf()
val gitHubLinks = arrayListOf(
@@ -518,11 +512,9 @@ val availableLists = mapOf, String>(
val availablePermutations = mapOf<(List) -> List, String>(
Pair({ it -> it.with(gitHubLinks) }, ".with(gitHubLinks)"),
Pair({ it -> it.asURI() }, ".asURI()"),
- Pair({ it -> it.asLocalURI() }, ".asLocalURI()"),
Pair({ it -> it.asRemoteURI() }, ".asRemoteURI()"),
Pair({ it -> it.asRemoteImageURI() }, ".asRemoteImageURI()"),
Pair({ it -> it.asURI().with(gitHubLinks) }, ".asURI().with(gitHubLinks)"),
- Pair({ it -> it.asLocalURI().with(gitHubLinks) }, ".asLocalURI().with(gitHubLinks)"),
Pair({ it -> it.asRemoteURI().with(gitHubLinks) }, ".asRemoteURI().with(gitHubLinks)"),
Pair({ it -> it.asRemoteImageURI().with(gitHubLinks) }, ".asRemoteImageURI().with(gitHubLinks)")
)
diff --git a/src/test/java/com/vladsch/idea/multimarkdown/util/TestGitHubVcsRoot_Basic.kt b/src/test/java/com/vladsch/idea/multimarkdown/util/TestGitHubLinkResolver_normalizedLinkRef.kt
similarity index 97%
rename from src/test/java/com/vladsch/idea/multimarkdown/util/TestGitHubVcsRoot_Basic.kt
rename to src/test/java/com/vladsch/idea/multimarkdown/util/TestGitHubLinkResolver_normalizedLinkRef.kt
index 6021f248..7416329d 100644
--- a/src/test/java/com/vladsch/idea/multimarkdown/util/TestGitHubVcsRoot_Basic.kt
+++ b/src/test/java/com/vladsch/idea/multimarkdown/util/TestGitHubLinkResolver_normalizedLinkRef.kt
@@ -25,9 +25,9 @@ import kotlin.test.assertEquals
@RunWith(value = Parameterized::class)
//arrayOf("fullPath", "linkType", "linkRef", "linkAnchor", "options", "optionsText", "multiResolve") * /
-class TestGitHubVcsRoot_Basic constructor(val rowId: Int, val containingFile: String
- , val linkAddress: String
- , val normalizedAddress: String
+class TestGitHubLinkResolver_normalizedLinkRef constructor(val rowId: Int, val containingFile: String
+ , val linkAddress: String
+ , val normalizedAddress: String
) {
val projectResolver: LinkResolver.ProjectResolver = MarkdownTestData
val containingFileRef = FileRef(containingFile)
@@ -64,7 +64,7 @@ class TestGitHubVcsRoot_Basic constructor(val rowId: Int, val containingFile: St
fun data(): Collection> {
val data = completionData
val amendedData = ArrayList>()
- val cleanData = true
+ val cleanData = false
var i = 0
for (row in data) {
diff --git a/src/test/java/com/vladsch/idea/multimarkdown/util/TestLinkResolver_Basic_Readme.kt b/src/test/java/com/vladsch/idea/multimarkdown/util/TestLinkResolver_Basic_Readme.kt
index 98de4a8d..763afe84 100644
--- a/src/test/java/com/vladsch/idea/multimarkdown/util/TestLinkResolver_Basic_Readme.kt
+++ b/src/test/java/com/vladsch/idea/multimarkdown/util/TestLinkResolver_Basic_Readme.kt
@@ -112,7 +112,7 @@ class TestLinkResolver_Basic_Readme constructor(val rowId: Int, val fullPath: St
val targetRef = resolver.resolve(linkRef, LinkResolver.ANY, fileList)
val uriRef = resolver.resolve(linkRef, LinkResolver.ONLY_URI, fileList)
val href = if (targetRef != null && targetRef is FileRef && this.uriText != null) {
- "file://" + targetRef.filePath
+ "file://" + targetRef.filePath.replace(" ", "%20").replace("#", "%23")
} else if (targetRef is LinkRef) targetRef.filePathWithAnchor
else null
assertEqualsMessage("LinkResolver.ONLY_URI link address does not match ${resolver.getMatcher(linkRef, false).linkAllMatch}", href, (uriRef as? LinkRef)?.filePathWithAnchor)
diff --git a/src/test/java/com/vladsch/idea/multimarkdown/util/UtilTestSuite.java b/src/test/java/com/vladsch/idea/multimarkdown/util/UtilTestSuite.java
index 1ee6511e..82a28dc8 100644
--- a/src/test/java/com/vladsch/idea/multimarkdown/util/UtilTestSuite.java
+++ b/src/test/java/com/vladsch/idea/multimarkdown/util/UtilTestSuite.java
@@ -30,7 +30,7 @@
TestLinkRef.class,
TestLinkRef_from.class,
TestLinkMatcher_MultiSub.class,
- TestGitHubVcsRoot_Basic.class,
+ TestGitHubLinkResolver_normalizedLinkRef.class,
TestLinkResolver_Basic_wiki_Home.class,
TestLinkResolver_Basic_wiki_normal_file.class,
TestLinkResolver_Basic_Readme.class,