Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL support? #60

Open
stevenvachon opened this issue Apr 19, 2017 · 10 comments
Open

URL support? #60

stevenvachon opened this issue Apr 19, 2017 · 10 comments

Comments

@stevenvachon
Copy link

stevenvachon commented Apr 19, 2017

const {URL} = require("url");
const url1 = "http://domain1/";
const url2 = "http://domain2/";

expect( new URL(url1) ).to.containSubset( new URL(url2) );
expect({ key:new URL(url1) }).to.containSubset({ key:new URL(url2) });

// none throw when both should

This works, however:

expect( new URL(url1) ).to.containSubset({ href:url1 });
expect( new URL(url1) ).to.not.containSubset({ href:url2 });
expect({ key:new URL(url1) }).to.containSubset({ key:{ href:url1 } });
expect({ key:new URL(url1) }).to.not.containSubset({ key:{ href:url2 } });
@stevenvachon
Copy link
Author

stevenvachon commented Apr 19, 2017

I'm not sure how to PR this, as detecting a URL would require a dependency:

const isURL = require('isurl');

if (isURL.lenient(expected)) {
	if (isURL.lenient(actual)) {
		return expected.href === actual.href;
	} else {
		return false;
	}
}

... and this lib has been written as a UMD module.

@eagleeye
Copy link
Contributor

eagleeye commented Apr 19, 2017

This module is not going to support any non-standard objects. Since you can do a workaround - please do a workaround or create separate module.

@stevenvachon
Copy link
Author

stevenvachon commented Apr 19, 2017

Non-standard?

https://url.spec.whatwg.org
https://developer.mozilla.org/en/docs/Web/API/URL

This module supports Date, which is no more standard than URL.

@eagleeye
Copy link
Contributor

you are right, didn't noticed that there is a standart URL object. I'll keep this issue open, until I'll find some good clues, what to do with this

@eagleeye eagleeye reopened this Apr 19, 2017
@stevenvachon
Copy link
Author

stevenvachon commented Apr 19, 2017

I have written isurl, which works cross-realm -- something that this module's Date check should also do in order to support Worker and Node's cluster. But I'm not sure how to get dependencies in without adding a build step since this module is UMD.

@stevenvachon
Copy link
Author

You can probably just copy what is being done here: JamesMGreene/chai-deep-match#2 (comment)

stevenvachon added a commit to stevenvachon/chai-subset that referenced this issue Apr 27, 2017
stevenvachon added a commit to stevenvachon/chai-subset that referenced this issue Apr 27, 2017
@JamesMGreene
Copy link

It may have a standard but, as I mention many times in JamesMGreene/chai-deep-match#2, I find it to be extremely un-semantic. 👎

@stevenvachon
Copy link
Author

@JamesMGreene it's an evolving standard. Feel free to assert your thoughts: https://github.com/whatwg/url/issues

@JamesMGreene
Copy link

@stevenvachon: Thanks for the info, I will.

@stevenvachon
Copy link
Author

Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants