Skip to content

path::normalize and //Β #3430

Description

@jesse99

Posix pahs like "/foo//bar" should be normalized to "/foo/bar". (WIndows likely has similar issues). Here is a test case:

// rustc --test normalize.rs && ./normalize
use std;
use Path = path::Path;

macro_rules! assert_equal (($expected: expr, $actual: expr) => 
{
    let a = $actual;        // only evaluate the expressions once
    let e = $expected;
    if a != e
    {
        fail fmt!("Found '%?', but expected '%?'", a, e);
    }
})

// TODO: add a windows version of this
#[cfg(unix)]
fn root() -> Path
{
    path::from_str(~"/tmp/")
}

#[test]
fn tester()
{
    let path = root();
    let path = path.push("/hmm");
    let path = path.normalize();
    assert_equal!(~"/tmp/hmm", path.to_str());
}

Activity

  1. added a commit that references this issue on May 17, 2020
    53a9805
  2. added a commit that references this issue on May 15, 2021
  3. added a commit that references this issue on Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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