It is simplest to use an option profile, but custom configurations are still possible.
options.defaultPorts
Type: Object
Default value: {}
A map of protocol default ports. Be sure to include the suffixed ":" in the key. Common protocols already have their ports removed.
options.directoryIndexes
Type: Object
Default value: {'index.html':true}
A map of file names to be treated as directory indexes.
options.ignoreDefaultPort
Type: Boolean or Function
Default value: true
When set to true or a function that returns true, a URL's port that matches any found in defaultPorts will be ignored during comparison.
options.ignoreDirectoryIndex
Type: Boolean or Function
Default value: Function
When set to true or a function that returns true, a URL's file name that matches any found in directoryIndexes will be ignored during comparison.
options.ignoreEmptyQueries
Type: Boolean or Function
Default value: Function
When set to true, a URL's empty query parameters (such as "?=") will not distinguish one URL from another. This option will be silently skipped if the input URLs do not support URLSearchParams.
Note: ignoreQueryOrder must be enabled.
options.ignoreQueryOrder
Type: Boolean or Function
Default value: Function
When set to true, the order of unique query parameters will not distinguish one URL from another. This option will be silently skipped if the input URLs do not support URLSearchParams.
options.ignoreWWW
Type: Boolean or Function
Default value: Function
When set to true or a function that returns true, a URL's "www" subdomain will be ignored during comparison.
Function as an Option
When an option is defined as a Function, it must return true to be included in the custom filter:
const options = { ignoreDirectoryIndex: function(url1, url2) { // Only URLs with these protocols will have their directory indexes ignored return url1.protocol === 'http:' && url1.protocol === 'https:'; }};
Option Profiles
TRUSTED_PROFILE, the default profile, is useful for a URL to a known server that you expect to be correctly configured.
UNTRUSTED_PROFILE is useful for a URL to an unknown or third-party server that could be incorrectly configured, particularly any algorithms that do not meet the URL specification.
Note: there are a few breaks in the linearity of these values:
AUTH is prioritized afterHOST because matching authentication on a different domain is pointless.
TLD is prioritized beforeDOMAIN because matching a domain on a different top-level domain is pointless.
SUBDOMAIN is prioritized afterDOMAIN.
Browserify/etc
Due to extreme file size in correctly parsing domains, browser builds will not include such functionality by default. As a result, output of this library within a web browser will never exactly equal TLD, DOMAIN nor SUBDOMAIN.