diff options
| author | jules@lens <julescarbon@gmail.com> | 2019-04-02 20:36:51 +0200 |
|---|---|---|
| committer | jules@lens <julescarbon@gmail.com> | 2019-04-02 20:36:51 +0200 |
| commit | 1d238346b5609e9454a4917c75631a550b5b43d1 (patch) | |
| tree | 8a936e721e78c7b5948b303e6a1686c96b882d51 /client/util | |
| parent | b4b58f2279fb01fa0240006c460c0b5ec95c1126 (diff) | |
| parent | f58d41731fc07d94d594d5582aef203564f990ec (diff) | |
Merge branch 'master' of asdf.us:megapixels_dev
Diffstat (limited to 'client/util')
| -rw-r--r-- | client/util/index.js | 9 |
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 => { |
