From c1738811bc8f131dba1a5accb1d6a98ec7f946e1 Mon Sep 17 00:00:00 2001 From: Justin Tew Date: Tue, 6 Oct 2020 15:40:53 -0700 Subject: [PATCH 1/2] Added getProtocol --- snippets/getProtocol.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 snippets/getProtocol.md diff --git a/snippets/getProtocol.md b/snippets/getProtocol.md new file mode 100644 index 000000000..52bc79f95 --- /dev/null +++ b/snippets/getProtocol.md @@ -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:' +``` From 484bae16afc58440c401eb32efb8b10da9b5866f Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 8 Oct 2020 15:24:58 +0300 Subject: [PATCH 2/2] Update getProtocol.md --- snippets/getProtocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/getProtocol.md b/snippets/getProtocol.md index 52bc79f95..9139116cb 100644 --- a/snippets/getProtocol.md +++ b/snippets/getProtocol.md @@ -5,7 +5,7 @@ tags: browser,beginner Returns the protocol being used on the current page. -- Can be either `http:` or `https:` +- Use `window.location.protocol` to get the protocol (`http:` or `https:`) of the current page. ```js const getProtocol = () => window.location.protocol;