Added getProtocol

This commit is contained in:
Justin Tew
2020-10-06 15:40:53 -07:00
parent 9c491967ed
commit c1738811bc

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.
- Can be either `http:` or `https:`
```js
const getProtocol = () => window.location.protocol;
```
```js
getProtocol(); // 'https:'
```