Skip to content

file:resolve-path depends on whether the specified path exists #2457

Open
@ruv

Description

@ruv

Description of the Problem

The function file:resolve-path( $path ) returns different results depending on whether the specified $path is an existing directory or not. Namely, it preserves the trailing slash in the first case, and removes it in the second case.

For example, if "/foo/bar" is an existing directory, file:resolve-path( "/foo/bar/" ) returns "/foo/bar/", otherwise it returns "/foo/bar" (i.e., the trailing slash is removed).

This behavior is not specified in the documentaion.

Expected Behavior

In the steps 1 and 3 below the result should be the same.

Steps to Reproduce the Behavior

  1. Run Xquery
file:resolve-path( "/foo/bar/" )
  1. Create directory
mkdir -p /foo/bar/
  1. Run Xquery
file:resolve-path( "/foo/bar/" )

Do you have an idea how to solve the issue?

I think, this function should not depend on existing files.

Regarding normalization, the expected behavior is that a trailing slash is preserved, because file:current-dir() and file:base-dir() return the path with a trailing slash, and fn:resolve-uri preserves the trailing slashes.

Update: According to EXPath File Module 4.0 / file:resolve-path, "If $path is an absolute path, it is returned unchanged".

See also: #1176

What is your configuration?

BaseX 11.8 beta a315259

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