Node | urlObject.slashes API
The urlObject.slashes property is used when one wants to check whether there is a need of 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.
Below programs illustrates the use of urlObject.slashes property:
Example 1:
// Node program to demonstrate the // urlObject.slashes API as Setter // Importing the module 'url-parse' var parse = require('url-parse'); // Use command 'npm install url-parse' in // command prompt to import this module var url = parse('www.geeksforgeeks.org'); // Display result in console console.log(url.slashes); |
Output:
false
Example 2:
// Node program to demonstrate the // urlObject.slashes API as Setter // Importing the module 'url-parse' var parse = require('url-parse'), // Disaply the result in console view 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
Recommended Posts:
- Node.js | NPM (Node Package Manager)
- PHP vs. Node.js
- Why Node.js ?
- Node js | OS
- Routing in Node.js
- Node.js | pop() function
- Node | URL.hostname API
- Node | URL.pathToFileURL API
- Promises in Node.js
- Node | URLSearchParams.has()
- Node | URL.fileURLToPath API
- Node | URL.resolve(from,to) API
- Node | URL.origin API
- Node | URL.username API
- Node | URL.search API
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



