Skip to content

Commit 5d9a70c

Browse files
committed
Merge branch 'fix/gitlens-uri'
2 parents 5bd46dd + 73c0624 commit 5d9a70c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/main/java/com/github/_1c_syntax/utils/Absolute.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ private static String encodePath(String path) {
8888
.replace(" ", "%20")
8989
.replace("[", "%91")
9090
.replace("]", "%93")
91+
.replace("?", "%3F")
92+
.replace("{", "%7B")
93+
.replace("}", "%7D")
94+
.replace(":", "%3A")
95+
.replace("\"", "%22")
96+
.replace("\\", "%5C")
9197
;
9298
}
9399

src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,28 @@ void testUriFromStringWithBrackets() {
148148
assertThat(uri.toString()).doesNotContain("[");
149149
assertThat(uri.toString()).doesNotContain("]");
150150
}
151+
152+
@Test
153+
void testUriFromGitLens() {
154+
// given
155+
var uriString = "gitlens://d5ff5b3/d%3A/git/repo/src/cf/Documents/Some/Ext/ObjectModule.bsl?%7B%22path%22%3A%22%2Fd%3A%2Fgit%2Frepo%2Fsrc%2Fcf%2FDocuments%2FSome%2FExt%2FObjectModule.bsl%22%2C%22ref%22%3A%22d5ff5b3c52bdd1f26f838944ec99f62346d2771b%22%2C%22repoPath%22%3A%22d%3A%2Fgit%2Frepo%22%7D";
156+
157+
// when
158+
var uri = Absolute.uri(uriString);
159+
160+
// then
161+
assertThat(uri.getPath()).endsWith("\"repoPath\":\"d:/git/repo\"}");
162+
}
163+
164+
@Test
165+
void testUriFromGit() {
166+
// given
167+
var uriString = "git:/e%3A/user/repo/Some/Module.bsl?%7B%22path%22%3A%22e%3A%5C%5Cuser%5C%5Crepo%5C%5CSome%5C%5CModule.bsl%22%2C%22ref%22%3A%22~%22%7D";
168+
169+
// when
170+
var uri = Absolute.uri(uriString);
171+
172+
// then
173+
assertThat(uri.getPath()).endsWith("\"ref\":\"~\"}");
174+
}
151175
}

0 commit comments

Comments
 (0)