less/less.js — pull request #1475 by rjgotten (2013-08-07 09:02:48+00:00)
Title: Apply path normalization in compiled CSS

This pull request adds a path normalization feature to `evalEnv` and calls it from both `tree.import` and `tree.URL` nodes to ensure that paths with `..` or `.` segments inside them, [as exhibited in a comment on #1470](https://github.com/less/less.js/issues/1470#issuecomment-22174938), are cleaned up properly. For example:
`@import "foo/bar/../baz.css"` becomes `@import "foo/baz.css"`,
`url("foo/bar/../baz.jpg")` becomes `url("foo/baz.jpg")`,
etc.

When a rootpath is specified or relative URL rewriting is enabled and a path is inherited from it, then those paths will be honored and combined with the URL before normalization. For example:
`url("../baz.jpg")` inside a sheet imported as `@import "foo/bar.less"` will have an intermediate representation of `url("foo/../baz.jpg")` which will be normalized and output as `url("baz.jpg")`.

When URL normalization cannot completely eliminate `..` segments by traversing up directories, then it will retain any remaining leading `..` segments. For example, as a variation on the previous:
`url("../../baz.jpg")` inside a sheet imported as `@import "foo/bar.less"` will become `url("../baz.jpg")`.

Unit tests have been updated to reflect normalized URLs.