summaryrefslogtreecommitdiff
path: root/client/util/index.js
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2019-04-01 20:14:10 +0200
committeradamhrv <adam@ahprojects.com>2019-04-01 20:14:10 +0200
commit4288f77297eb0dd36f8206ffbce812223b299ffb (patch)
tree7e9c23ec1b3a832e031a5c22ff29700eb5929656 /client/util/index.js
parent54a9853e9dce4a2c00208c80e49b6d6497d50886 (diff)
parent25f850aedbdddd17e0de8c5f2a41aace58c1413f (diff)
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'client/util/index.js')
-rw-r--r--client/util/index.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/client/util/index.js b/client/util/index.js
index 87d32ebb..e90e5466 100644
--- a/client/util/index.js
+++ b/client/util/index.js
@@ -63,6 +63,15 @@ export const percent = n => (n * 100).toFixed(1) + '%'
export const px = (n, w) => Math.round(n * w) + 'px'
export const clamp = (n, a, b) => n < a ? a : n < b ? n : b
+export const domainFromUrl = url => {
+ const partz = url.split('/')[2].split('.')
+ if (partz.length > 2 && partz[partz.length - 2].length == 2) {
+ return partz.slice(-3).join('.')
+ } else {
+ return partz.slice(-2).join('.')
+ }
+}
+
/* URLs */
export const preloadImage = opt => {