Skip to content

Commit

Permalink
Merge branch 'fix/gitlens-uri'
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Sep 23, 2021
2 parents 5bd46dd + 73c0624 commit 5d9a70c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/github/_1c_syntax/utils/Absolute.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ private static String encodePath(String path) {
.replace(" ", "%20")
.replace("[", "%91")
.replace("]", "%93")
.replace("?", "%3F")
.replace("{", "%7B")
.replace("}", "%7D")
.replace(":", "%3A")
.replace("\"", "%22")
.replace("\\", "%5C")
;
}

Expand Down
24 changes: 24 additions & 0 deletions src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,28 @@ void testUriFromStringWithBrackets() {
assertThat(uri.toString()).doesNotContain("[");
assertThat(uri.toString()).doesNotContain("]");
}

@Test
void testUriFromGitLens() {
// given
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";

// when
var uri = Absolute.uri(uriString);

// then
assertThat(uri.getPath()).endsWith("\"repoPath\":\"d:/git/repo\"}");
}

@Test
void testUriFromGit() {
// given
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";

// when
var uri = Absolute.uri(uriString);

// then
assertThat(uri.getPath()).endsWith("\"ref\":\"~\"}");
}
}

0 comments on commit 5d9a70c

Please sign in to comment.