dalekjs / dalek

[unmaintained] DalekJS Base framework
MIT License
695 stars 63 forks source link

Methods to match relative URLs and URL parts #40

Open pepelsbey opened 10 years ago

pepelsbey commented 10 years ago

Right now it's possible to check the whole URL only which is less readable and doesn't work in unpredictable or static environment. It would be great to see more flexible URL matching.

My suggestions

When I pass relative URL like folder/index.html it becomes file:///Users/…/folder/index.html.

New relative() method could match URL relative to folder where dalek is launched

.open('folder/index.html')
.assert.url.relative('folder/index.html')

New methogs could match specific URL parts

.open('folder/index.html?param=value#hash')
.assert.url.param('param', 'value')
.assert.url.hash('hash')

There are more URL parts that could be checked (domain levels, etc.), but I think these are essential.

asciidisco commented 10 years ago

I like the idea. Luckily someone who is involved wrote a lovely little library called URI.js, maybe we can use it here. Looking at you @rodneyrehm

rodneyrehm commented 10 years ago

well, not sure how many comparison utiliies you'd want to expose here. I can think of too many things you want to test for (is it the proper filename? does the query string have the property Y? is it value X? does the URL in the fragment equal something… bla bla bla).

The OP concentrates on .assert.url - but really this applies to other things as well, e.g. .attr('a', 'href'). So we'd probably want to extend the chai imports or something?