Installations
npm install url
Releases
Unable to fetch releases
Developer
defunctzombie
Developer Guide
Module System
CommonJS
Min. Node Version
>= 0.4
Typescript Support
No
Node Version
22.5.1
NPM Version
10.8.2
Statistics
376 Stars
76 Commits
96 Forks
7 Watching
1 Branches
13 Contributors
Updated on 06 Aug 2024
Bundle Size
43.76 kB
Minified
13.57 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
5,417,880,390
Last day
-9.2%
3,818,937
Compared to previous day
Last week
1.7%
22,600,261
Compared to previous week
Last month
12.8%
92,505,838
Compared to previous month
Last year
-5.6%
989,813,971
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
node-url
This module has utilities for URL resolution and parsing meant to have feature parity with node.js core url module.
1var url = require('url');
api
Parsed URL objects have some or all of the following fields, depending on whether or not they exist in the URL string. Any parts that are not in the URL string will not be in the parsed object. Examples are shown for the URL
'http://user:pass@host.com:8080/p/a/t/h?query=string#hash'
-
href
: The full URL that was originally parsed. Both the protocol and host are lowercased.Example:
'http://user:pass@host.com:8080/p/a/t/h?query=string#hash'
-
protocol
: The request protocol, lowercased.Example:
'http:'
-
host
: The full lowercased host portion of the URL, including port information.Example:
'host.com:8080'
-
auth
: The authentication information portion of a URL.Example:
'user:pass'
-
hostname
: Just the lowercased hostname portion of the host.Example:
'host.com'
-
port
: The port number portion of the host.Example:
'8080'
-
pathname
: The path section of the URL, that comes after the host and before the query, including the initial slash if present.Example:
'/p/a/t/h'
-
search
: The 'query string' portion of the URL, including the leading question mark.Example:
'?query=string'
-
path
: Concatenation ofpathname
andsearch
.Example:
'/p/a/t/h?query=string'
-
query
: Either the 'params' portion of the query string, or a querystring-parsed object.Example:
'query=string'
or{'query':'string'}
-
hash
: The 'fragment' portion of the URL including the pound-sign.Example:
'#hash'
The following methods are provided by the URL module:
url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
Take a URL string, and return an object.
Pass true
as the second argument to also parse
the query string using the querystring
module.
Defaults to false
.
Pass true
as the third argument to treat //foo/bar
as
{ host: 'foo', pathname: '/bar' }
rather than
{ pathname: '//foo/bar' }
. Defaults to false
.
url.format(urlObj)
Take a parsed URL object, and return a formatted URL string.
href
will be ignored.protocol
is treated the same with or without the trailing:
(colon).- The protocols
http
,https
,ftp
,gopher
,file
will be postfixed with://
(colon-slash-slash). - All other protocols
mailto
,xmpp
,aim
,sftp
,foo
, etc will be postfixed with:
(colon)
- The protocols
auth
will be used if present.hostname
will only be used ifhost
is absent.port
will only be used ifhost
is absent.host
will be used in place ofhostname
andport
pathname
is treated the same with or without the leading/
(slash)search
will be used in place ofquery
query
(object; seequerystring
) will only be used ifsearch
is absent.search
is treated the same with or without the leading?
(question mark)hash
is treated the same with or without the leading#
(pound sign, anchor)
url.resolve(from, to)
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. Examples:
url.resolve('/one/two/three', 'four') // '/one/two/four'
url.resolve('http://example.com/', '/one') // 'http://example.com/one'
url.resolve('http://example.com/one', '/two') // 'http://example.com/two'
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 4/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rebase.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/defunctzombie/node-url/rebase.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/rebase.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/defunctzombie/node-url/rebase.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/require-allow-edits.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/defunctzombie/node-url/require-allow-edits.yml/master?enable=pin
- Info: 0 out of 1 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/rebase.yml:11
- Info: jobLevel 'pull-requests' permission set to 'read': .github/workflows/rebase.yml:12
- Warn: no topLevel permission defined: .github/workflows/node-aught.yml:1
- Warn: no topLevel permission defined: .github/workflows/node-pretest.yml:1
- Warn: no topLevel permission defined: .github/workflows/node-tens.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/rebase.yml:6
- Warn: no topLevel permission defined: .github/workflows/require-allow-edits.yml:1
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More