private String buildPathFrom(URI uri, String host) { String pathStr = uri.toString(); pathStr = pathStr.replace(host, ""); pathStr = pathStr.replace("git://", "").replace("default://", ""); pathStr = EncodingUtil.decode(pathStr); if (pathStr.startsWith("/:")) { pathStr = pathStr.substring(2); } return pathStr; }
private String destinationPath(final Path resource) { final String destinationPath = EncodingUtil.decode(resource.toUri().toString().substring(projectPrefix.length())); if (destinationPath.startsWith("/")) { // File in sub module return destinationPath.substring(1); } else { // File in main module return destinationPath; } }
final String _filename = EncodingUtil.decode(req.getRequestURI().substring(req.getContextPath().length())); final String filename; if (_filename.toLowerCase().endsWith("?preview")) {
@Test public void testSimpleBranchedGitRoot2Spaced() throws IllegalStateException { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, EncodingUtil.decode("/path/to/some/some%20place.txt"), "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/some place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/some%20place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isEqualTo("path"); assertThat(path.getRoot().toString()).isEqualTo("/"); }
@Test public void testSimpleBranchedGitRoot2Spaced() throws IllegalStateException { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, EncodingUtil.decode("/path/to/some/some%20place.txt"), "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/some place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/some%20place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isEqualTo("path"); assertThat(path.getRoot().toString()).isEqualTo("/"); }