Node.js urlObject.slashes API
Last Updated :
31 Mar, 2023
The urlObject.slashes property is used when one wants to check whether there is a need for ASCII valued forward-slash character (/) after the colon (:) in the protocol (HTTP or HTTPS) of a URL or not. It returns the Boolean value.
Syntax:
urlObject.slashes
Return Value: The urlObject.slashes property returns true if two ASCII value forward slashes are required, otherwise, it returns false.
Example 1: The below programs illustrate the use of urlObject.slashes property:
javascript
const parse = require( 'url-parse' );
const url = parse( 'www.geeksforgeeks.org' );
console.log(url.slashes);
|
Output:
false
Example 2:
javascript
const parse = require( 'url-parse' ),
console.log(url.slashes)
|
Output:
true
Note: The above program will compile and run by using the node app.js command.
Reference: https://nodejs.org/api/url.html#url_urlobject_slashes
Share your thoughts in the comments
Please Login to comment...