diff options
Diffstat (limited to 'src/lib/strings/url-helpers.ts')
-rw-r--r-- | src/lib/strings/url-helpers.ts | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts index 105c631bf..b509aad01 100644 --- a/src/lib/strings/url-helpers.ts +++ b/src/lib/strings/url-helpers.ts @@ -30,7 +30,7 @@ export function toNiceDomain(url: string): string { if (`https://${urlp.host}` === PROD_SERVICE) { return 'Bluesky Social' } - return urlp.host + return urlp.host ? urlp.host : url } catch (e) { return url } @@ -42,15 +42,12 @@ export function toShortUrl(url: string): string { if (urlp.protocol !== 'http:' && urlp.protocol !== 'https:') { return url } - const shortened = - urlp.host + - (urlp.pathname === '/' ? '' : urlp.pathname) + - urlp.search + - urlp.hash - if (shortened.length > 30) { - return shortened.slice(0, 27) + '...' + const path = + (urlp.pathname === '/' ? '' : urlp.pathname) + urlp.search + urlp.hash + if (path.length > 15) { + return urlp.host + path.slice(0, 13) + '...' } - return shortened ? shortened : url + return urlp.host + path } catch (e) { return url } |