Skip to content

@base prepend with a path, removes last folder if no end "/" #459

@ethieblin

Description

@ethieblin

If we expand a URI with "@base" not ending with a "/", we get a URI missing the last path fragment.
For example
"@base":"http://example.com/loutre" with"@id":"toto" gives http://example.com/toto when we would expect http://example.com/loutre/toto. If "@base" ends with a "/" it works fine.

Playground expansion without "/"

Playground expansion with "/"

This issue is only on URI expansion, but the behaviour is different on URI compaction : a "@base" with or without "/" will give the same URI fragment.
This will be a problem when round-tripping because the input URI will change after re-expansion.

Input: "@id":"http://example.com/loutre/toto"
Compaction with "@base":"http://example.com/loutre" gives

"@context": {
    "@base": "http://example.com/loutre"
  },
  "@id": "toto"

Which re-expanded gives "http://example.com/toto".

Playground compaction, "@base" without "/"

Proposed fix: ethieblin#2

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