Skip to content

KeySpaceUtils.pathToUri inserts extra / when path ends with NULL #3912

@ScottDugas

Description

@ScottDugas

KeySpaceUtils.pathToUri inserts extra / when path ends with NULL.

I created the following test:

    @Test
    void nullAtEnd() throws RelationalException {
        KeySpace keySpace = new KeySpace(
                createDirectory("null", KeySpaceDirectory.KeyType.NULL, true, null),
                createDirectory("parent", KeySpaceDirectory.KeyType.STRING, true, "parent")
                        .addSubdirectory(createDirectory("null", KeySpaceDirectory.KeyType.NULL, true, null)));
        URI rootUrl = URI.create("/");
        final KeySpacePath rootPath = keySpace.path("null");
        URI url = URI.create("/parent/");
        final KeySpacePath path = keySpace.path("parent").add("null");
        Assertions.assertAll(
                () -> Assertions.assertEquals(rootPath, KeySpaceUtils.toKeySpacePath(rootUrl, keySpace)),
                () -> Assertions.assertEquals(rootUrl, KeySpaceUtils.pathToUri(rootPath)),
                () -> Assertions.assertEquals(path, KeySpaceUtils.toKeySpacePath(url, keySpace)),
                () -> Assertions.assertEquals(url, KeySpaceUtils.pathToUri(path)));
    }

And it fails because the root produces // and the non-root produces /parent//.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions