public Path parse(final String uri) throws HostParserException {
        final Host host = new HostParser(factory).get(uri);
        if(StringUtils.isBlank(host.getDefaultPath())) {
            return new Path(String.valueOf(Path.DELIMITER), EnumSet.of((Path.Type.directory)));
        }
        switch(new ContainerPathKindDetector(host.getProtocol().getFeature(PathContainerService.class)).detect(host.getDefaultPath())) {
            case directory:
                return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(Path.Type.directory,
                        Path.Type.volume));
        }
        return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(
                new DelimiterPathKindDetector().detect(host.getDefaultPath())));
    }
@Test
    public void testParse() throws Exception {
        final CommandLineParser parser = new PosixParser();
        final CommandLine input = parser.parse(new Options(), new String[]{});
        final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Arrays.asList(new FTPTLSProtocol(), new S3Protocol())));
        factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/FTP.cyberduckprofile")));
        factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/FTPS.cyberduckprofile")));
        factory.register(new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/S3 (HTTPS).cyberduckprofile")));

        assertEquals(new Path("/", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/"));
        assertEquals(new Path("/d", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/d/"));
        assertEquals(new Path("/d", EnumSet.of(Path.Type.file)),
                new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/d"));
        assertEquals(new Path("/", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/"));
        assertEquals(new Path("/", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch"));

        assertEquals(new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("s3:u@test.cyberduck.ch/"));
        assertEquals(new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("s3:u@test.cyberduck.ch/"));
        assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("s3:u@test.cyberduck.ch/d/"));

        assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.directory)),
                new CommandLinePathParser(input, factory).parse("s3://u@/test.cyberduck.ch/d/"));
        assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.file)),
                new CommandLinePathParser(input, factory).parse("s3://u@/test.cyberduck.ch/d"));
        assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.file)),
                new CommandLinePathParser(input, factory).parse("s3://u@/test.cyberduck.ch/d"));

        // Test bucket
        assertEquals(new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)),
                new CommandLinePathParser(input, factory).parse("s3:/test.cyberduck.ch"));
    }