Merge pull request #1365 from gustsu/getProtocol-snippet

Added getProtocol
This commit is contained in:
Angelos Chalaris
2020-10-08 15:25:12 +03:00
committed by GitHub

16
snippets/getProtocol.md Normal file
View File

@ -0,0 +1,16 @@
---
title: getProtocol
tags: browser,beginner
---
Returns the protocol being used on the current page.
- Use `window.location.protocol` to get the protocol (`http:` or `https:`) of the current page.
```js
const getProtocol = () => window.location.protocol;
```
```js
getProtocol(); // 'https:'
```