forked from ringo/ringojs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize resource paths before looking them up.
This should fix lookups of classpath resources failing with non-normalized paths.
- Loading branch information
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.ringojs.test; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import static org.ringojs.engine.RhinoEngine.normalizePath; | ||
|
||
public class NormalizePathTest extends TestCase { | ||
|
||
public void test1() { | ||
String path = normalizePath("../bar/../foo/baz"); | ||
assertEquals(path, "../foo/baz"); | ||
} | ||
|
||
public void test2() { | ||
String path = normalizePath("./bar/.//../foo/baz"); | ||
assertEquals(path, "foo/baz"); | ||
} | ||
|
||
public void test3() { | ||
String path = normalizePath("bar/foo/baz"); | ||
assertEquals(path, "bar/foo/baz"); | ||
} | ||
|
||
public void test4() { | ||
String path = normalizePath("/bar/foo/baz/../BAZ"); | ||
assertEquals(path, "/bar/foo/BAZ"); | ||
} | ||
|
||
public void test5() { | ||
String path = normalizePath("bar//foo/./../baz/../../"); | ||
assertEquals(path, ""); | ||
} | ||
|
||
public void test6() { | ||
String path = normalizePath("bar/../foo/./../baz/../../../"); | ||
assertEquals(path, "../.."); | ||
} | ||
} |