-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fix(core): Improve domain and url matching for extractDomain …
- Loading branch information
1 parent
a74284b
commit bde5397
Showing
2 changed files
with
25 additions
and
153 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 |
---|---|---|
|
@@ -97,43 +97,13 @@ describe('Data Transformation Functions', () => { | |
|
||
test('.isUrl should work on a string', () => { | ||
expect(evaluate('={{ "https://example.com/".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "http://example.com/".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "ftp://example.com/".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "example.com".isUrl() }}')).toEqual(false); | ||
expect(evaluate('={{ "www.example.com".isUrl() }}')).toEqual(false); | ||
expect(evaluate('={{ "https://www.example.com/".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "https://example.com/path".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "https://example.com/path?query=1".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "https://example.com/path#fragment".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "https://example.com:8080".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "https://example.com?query=1".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "https://example.com#fragment".isUrl() }}')).toEqual(true); | ||
expect(evaluate('={{ "example.com/path".isUrl() }}')).toEqual(false); | ||
expect(evaluate('={{ "http:///".isUrl() }}')).toEqual(false); | ||
expect(evaluate('={{ "https://".isUrl() }}')).toEqual(false); | ||
expect(evaluate('={{ "example".isUrl() }}')).toEqual(false); | ||
expect(evaluate('={{ "".isUrl() }}')).toEqual(false); | ||
}); | ||
|
||
test('.isDomain should work on a string', () => { | ||
expect(evaluate('={{ "example.com".isDomain() }}')).toEqual(true); | ||
expect(evaluate('={{ "asdf".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "https://example.com/".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "www.example.com".isDomain() }}')).toEqual(true); | ||
expect(evaluate('={{ "subdomain.example.com".isDomain() }}')).toEqual(true); | ||
expect(evaluate('={{ "example.co.uk".isDomain() }}')).toEqual(true); | ||
expect(evaluate('={{ "example".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "example.".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ ".com".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "example..com".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "example_com".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "example/com".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "example com".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "www.example..com".isDomain() }}')).toEqual(false); | ||
expect(evaluate('={{ "123.com".isDomain() }}')).toEqual(true); | ||
expect(evaluate('={{ "xn--80aswg.xn--p1ai".isDomain() }}')).toEqual(true); // Punycode domain | ||
expect(evaluate('={{ "example.com:8080".isDomain() }}')).toEqual(true); | ||
expect(evaluate('={{ "".isDomain() }}')).toEqual(false); | ||
}); | ||
|
||
test('.toSnakeCase should work on a string', () => { | ||
|
@@ -157,43 +127,11 @@ describe('Data Transformation Functions', () => { | |
'={{ "I am a test with a url: https://example.net/ and I am a test with an email: [email protected]".extractUrl() }}', | ||
), | ||
).toEqual('https://example.net/'); | ||
expect(evaluate('={{ "Check this out: https://subdomain.example.com:3000/path?q=1#hash".extractUrl() }}')).toEqual('https://subdomain.example.com:3000/path?q=1#hash'); | ||
expect(evaluate('={{ "Invalid URL: http:///example.com".extractUrl() }}')).toEqual(undefined); | ||
expect(evaluate('={{ "Mixed content: https://www.example.com and http://www.example.org".extractUrl() }}')).toEqual('https://www.example.com'); | ||
expect(evaluate('={{ "Text without URL: This is just a simple text".extractUrl() }}')).toEqual(undefined); | ||
expect(evaluate('={{ "URL with Unicode: http://www.xn--80aswg.xn--j1amh".extractUrl() }}')).toEqual('http://www.xn--80aswg.xn--j1amh'); | ||
expect(evaluate('={{ "Localhost URL: http://localhost:8080/test?x=1".extractUrl() }}')).toEqual('http://localhost:8080/test?x=1'); | ||
expect(evaluate('={{ "IP URL: http://192.168.1.1:8000/path?q=value#frag".extractUrl() }}')).toEqual('http://192.168.1.1:8000/path?q=value#frag'); | ||
}); | ||
|
||
test('.extractDomain should work on a string', () => { | ||
expect(evaluate('={{ "[email protected]".extractDomain() }}')).toEqual('example.org'); | ||
expect(evaluate('={{ "https://example.org/".extractDomain() }}')).toEqual('example.org'); | ||
expect(evaluate('={{ "https://www.google.com".extractDomain() }}')).toEqual('www.google.com'); | ||
expect(evaluate('={{ "http://example.org".extractDomain() }}')).toEqual('example.org'); | ||
expect(evaluate('={{ "ftp://ftp.example.com".extractDomain() }}')).toEqual('ftp.example.com'); | ||
expect(evaluate('={{ "google.com".extractDomain() }}')).toEqual('google.com'); | ||
expect(evaluate('={{ "www.example.net".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "//example.com".extractDomain() }}')).toEqual('example.com'); | ||
expect(evaluate('={{ "mailto:[email protected]".extractDomain() }}')).toEqual('example.com'); | ||
expect(evaluate('={{ "tel:+1-555-123-4567".extractDomain() }}')).toEqual(undefined); | ||
expect(evaluate('={{ "[email protected]".extractDomain() }}')).toEqual('example.org'); | ||
expect(evaluate('={{ "[email protected]".extractDomain() }}')).toEqual('example.com'); | ||
expect(evaluate('={{ "[email protected]".extractDomain() }}')).toEqual('example.co.uk'); | ||
expect(evaluate('={{ "[email protected]".extractDomain() }}')).toEqual('subdomain.example.com'); | ||
expect(evaluate('={{ "www.example.net?test=1213".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "www.example.net?test".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "www.example.net#tesdt123".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "https://www.example.net?test=1213".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "https://www.example.net?test".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "https://www.example.net#tesdt123".extractDomain() }}')).toEqual('www.example.net'); | ||
expect(evaluate('={{ "https://192.168.1.1".extractDomain() }}')).toEqual('192.168.1.1'); | ||
expect(evaluate('={{ "http://www.xn--80aswg.xn--j1amh".extractDomain() }}')).toEqual('www.xn--80aswg.xn--j1amh'); | ||
expect(evaluate('={{ "https://localhost".extractDomain() }}')).toEqual('localhost'); | ||
expect(evaluate('={{ "https://localhost?test=123".extractDomain() }}')).toEqual('localhost'); | ||
expect(evaluate('={{ "https://www.example_with_underscore.com".extractDomain() }}')).toEqual('www.example_with_underscore.com'); | ||
expect(evaluate('={{ "https://www.example.com:8080".extractDomain() }}')).toEqual('www.example.com'); | ||
expect(evaluate('={{ "https://example.space".extractDomain() }}')).toEqual('example.space'); | ||
}); | ||
|
||
test('.extractEmail should work on a string', () => { | ||
|