Node.js urlObject.slashes API

Last Updated : 17 Aug, 2026

Node.js urlObject.slashes is a legacy property that indicates whether a parsed URL contains two forward slashes (//) after its protocol. It is part of the object by url.parse() and is used when working with the older URL API.

  • urlObject.slashes is a boolean property that represents the presence of double slashes after the protocol.
  • It is set to true when the URL contains // after the protocol.
  • It is set to false when the URL does not include double slashes.

Syntax

urlObject.slashes

Where

  • urlObject : It represents the object returned by the url.parse() method.
  • slashes : It is a property of the urlObject that indicates the presence of // after the protocol.

Return Value: The urlObject.slashes property returns true if two ASCII value forward slashes are required, otherwise, it returns false.

Example 1:

javascript
// Importing the module 'url-parse'
const parse = require('url-parse'); 

// Use command 'npm install url-parse' in
// command prompt to import this module
const url = parse('www.geeksforgeeks.org');

// Display result in console
console.log(url.slashes);

Output

false

Example 2:  

javascript
// Importing the module 'url-parse'
const parse = require('url-parse'), 
url = parse('https://example.com/geek/login');

// Display the result in console view
console.log(url.slashes)

Output

true

Use Cases of urlObject.slashes API

  • It is used to check whether a URL includes // after the protocol.
  • It helps in correctly reconstructing or formatting URLs in legacy code.
  • It is useful when handling or validating URLs parsed using url.parse().
  • It assists in maintaining compatibility with older Node.js URL handling logic.

Reference: https://nodejs.org/api/url.html#url_urlobject_slashes 

Comment

Explore