- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
NodeJS - urlObject.slashes Property
The NodeJS urlObject.slashes property of urlObject retrieves a Boolean value. The returned value will be true, if two ASCII forward slashes (//) are required after the colon (:) in the protocol segment of the URL. Else, the returned value is false.
The URL (Uniform Resource Locator) is a unique web address for a specific resource present in the various web servers.
The protocols present in the URL specify how data is transferred between the host and a web browser. The most common protocols you find the URLs are HTTP and HTTPS (secure), but there are other internet protocols such as FTP, UDP, POP, SMTP, DNS, etc.
Syntax
Following is the syntax of the NodeJS urlObject.slashes property
urlObject.slashes
Parameters
This property does not accept any parameters.
Return Value
This property returns a Boolean value. It will return true, if two ASCII forward-slash characters (//) are required after the colon in the protocol segment. Else, it returns false.
Example
In this example, we are checking whether there is a need for two ASCII forward-slash (//) after the colon (:) in the protocol of a URL.
const url = require('url'); console.log(url.parse('ARP://site.com').slashes); console.log(url.parse('DHCP://site.com').slashes); console.log(url.parse('IMAP4://site.com').slashes); console.log(url.parse('SIP://site.com').slashes); console.log(url.parse('RTP://site.com').slashes); console.log(url.parse('RLP://site.com').slashes); console.log(url.parse('RAP://site.com').slashes); console.log(url.parse('L2TP://site.com').slashes); console.log(url.parse('PPTP://site.com').slashes); console.log(url.parse('SNMP://site.com').slashes); console.log(url.parse('TFTP://site.com').slashes);
Output
Following is the output of the above program
The slashes property returns true because all the protocols in the above program require ASCII forward slashes.
true true true true true true true true true true true
Example
In this example, we are checking with some other protocols whether it requires two ASCII forward-slash (//) characters after the colon (:) or not.
console.log(url.parse('TCP://site.com').slashes); console.log(url.parse('IP://site.com').slashes); console.log(url.parse('UDP://site.com').slashes); console.log(url.parse('POP://site.com').slashes); console.log(url.parse('SMTP://site.com').slashes); console.log(url.parse('FTP://site.com').slashes); console.log(url.parse('HTTP://site.com').slashes); console.log(url.parse('HTTPS://site.com').slashes);
Output
As we can see in the output below, the slashes property returns true because all the protocols in the above program require ASCII forward slashes.
true true true true true true true true
To Continue Learning Please Login
Login with Google