Skip to content

Commit

Permalink
Merge pull request #81 from fmazoyer/windows-path-in-replace-branch
Browse files Browse the repository at this point in the history
Fixed #80 - take backslash into account in TOKENIZER for Windows path
  • Loading branch information
raydac committed Jan 28, 2021
2 parents 40f7b18 + 12ac6f5 commit ca26bba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public final class GoMod {

private static final Pattern TOKENIZER =
Pattern.compile("(\\/\\/|\\\"[^\\\"]+\\\"|[<>=\\w.+\\-/]+|[<>=-]+|\\(|\\)|[\\s\\n]+)");
Pattern.compile("(\\/\\/|\\\"[^\\\"]+\\\"|[<>=\\w.+\\-/\\\\]+|[<>=-]+|\\(|\\)|[\\s\\n]+)");
private final List<GoModItem> items;

private GoMod(@Nonnull @MustNotContainNull final List<GoModItem> items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ public void testComplex4() {
+ "replace example.com/me/goodbye => ../goodbye", model.toString());
}

@Test
public void testComplex4WindowsPath() {
final GoMod model = GoMod.from("module example.com/me/hello\n"
+ "\n"
+ " require (\n"
+ " example.com/me/goodbye v0.0.0\n"
+ " rsc.io/quote v1.5.2\n"
+ " )\n"
+ "\n"
+ " replace example.com/me/goodbye => ..\\..\\goodbye");
assertEquals(4, model.size());

assertEquals("module example.com/me/hello\n"
+ "require example.com/me/goodbye v0.0.0\n"
+ "require rsc.io/quote v1.5.2\n"
+ "replace example.com/me/goodbye => ..\\..\\goodbye", model.toString());
}

@Test
public void testComplex5() {
final GoMod model = GoMod.from("module github.com/example/project\n"
Expand Down

0 comments on commit ca26bba

Please sign in to comment.