On Sat, Dec 7, 2013 at 2:17 PM, johnjbarton <notifications@github.com>wrote:

> In test/unit/runtime/System.js:
>
> > +    assert.equal(System.normalize('d/e/f'), './d/e/f');
> > +    // below baseURL
> > +    assert.equal('../e/f', System.normalize('../e/f'));
> > +
> > +    var refererName = './dir/file';
> > +    assert.equal(System.normalize('./d/e/f', refererName), './dir/d/e/f');
> > +    assert.equal(System.normalize('../e/f', refererName), './e/f');
> > +    // below referer
> > +    assert.equal(System.normalize('../../e/f', refererName), '../e/f');
> > +
> > +    var refererName = './x/y';
> > +    assert.equal(System.normalize('./d/e/f', refererName),'./x/d/e/f');
> > +    // internal system module
> > +    assert.equal(System.normalize('@abc/def'), '@abc/def');
> > +    // backwards compat
> > +    assert.equal(System.normalize('./a.js'), './a.js');
>
> (I don't see this reply on github :-()
> On Sat, Dec 7, 2013 at 10:29 AM, Erik Arvidsson <notifications@github.com>wrote:
> ... Can we also add this test?
> assert.equal(System.normalize('a/b/../c'),'a/b/../c');assert.equal(System.normalize('a/b/../c',
> refererName),'a/b/../c'); These are not relative so should be passed
> through as is. assert.equal(System.normalize('a/../b',
> refererName),'./dir/b'); I don't see how this part of the proposal can
> survive. The two primary use
> cases are browser URLs and file system names. In both cases 'a/b/../c'
> means 'a/c'. So if I have a project and in one part of the project I use
> 'a/b/../c' and another 'a/c', the only component of my system distinguishes
> them is System.normalize. That will be bad.
>  If we use removeDotSegments then this ends up being relative even though
> Jason's proposal does not allow '..' except at the beginning. We could
> throw on this if we wanted to?
> IMO these have to throw or they have to canonicalize. If I can write
> 'a/b/../c' then its normal form has to be 'a/c' not 'a/b/../c'. Is there
> any path into System.normalize() where devs can compute the name, eg import
> {foo} from amaze+confound; ? Maybe via dynamic load? If yes, then IMO the
> /../ has to be legal. Else throw is ok.
>

Agreed, either throw or canonicalize. Everyhing else is madness.

Personally I think it would be more consistent to canonicalize because that
is how URLs and file paths work. But if we throw early at least we will
never get into a crazy case.


> —
> Reply to this email directly or view it on GitHub<https://github.com/google/traceur-compiler/pull/519/files#r8182356>
> .
>



-- 
erik