@dub/utils 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var e={city:"San Francisco",region:"CA",country:"US",latitude:"37.7695",longitude:"-122.385"},s="63.141.57.109",p={hidden:{scale:.8,opacity:0},show:{scale:1,opacity:1,transition:{type:"spring"}}},a={hidden:{opacity:0,y:20},show:{opacity:1,y:0,transition:{duration:.4,type:"spring"}}},n={initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.15,ease:"easeOut"}},c={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2}},i=100,r="https://dub.co",l=new Set(["app.dub.co","preview.dub.co","localhost:8888","localhost"]),d=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"||process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://app.dub.co":"http://localhost:8888",u=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://app.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://preview.dub.co":process.env.NGROK_URL,_=new Set(["api.dub.co","api.dub.sh","api.localhost:8888","d296-2600-1700-2f70-6600-ddc9-59bd-9d63-8e50.ngrok-free.app"]),h=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://api.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://api.dub.sh":"http://api.localhost:8888",E=new Set(["admin.dub.co","admin.localhost:8888"]),g={home:"https://dub.co",dub:"https://dub.co",signin:"https://app.dub.co/login",login:"https://app.dub.co/login",register:"https://app.dub.co/register",signup:"https://app.dub.co/register",app:"https://app.dub.co",dashboard:"https://app.dub.co",links:"https://app.dub.co/links",settings:"https://app.dub.co/settings",welcome:"https://app.dub.co/welcome",discord:"https://twitter.com/dubdotco",tags:"https://dub.co/help/how-to-use-tags"},A={headers:{"x-powered-by":"Dub.co - Link management for modern marketing teams"}},I="/_static/favicons",L="https://www.google.com/s2/favicons?sz=64&domain_url=",N="https://d2vwwcvoksz7ty.cloudfront.net/logo.png",m="https://d2vwwcvoksz7ty.cloudfront.net/thumbnail.png",O=["tools","pricing","help","features","customers","blog","(blog-post)","login","register","auth"],S=[{name:"Metatags API",slug:"metatags"},{name:"Link Inspector",slug:"inspector"}],T=new Set(["com","co","net","org","edu","gov","in"]),b=new Set(["my.id","github.io","vercel.app","now.sh","pages.dev","webflow.io","netlify.app","fly.dev","web.app"]),x={key:"",url:"",domain:"",archived:!1,expiresAt:null,password:null,title:null,description:null,image:null,rewrite:!1,ios:null,android:null,clicks:0,userId:"",proxy:!1},w="cl7pj5kq4006835rbjlt2ofka",M=[{name:"Okta",logo:"/_static/icons/okta.svg",saml:"okta",samlModalCopy:"Metadata URL",scim:"okta-scim-v2",scimModalCopy:{url:"SCIM 2.0 Base URL",token:"OAuth Bearer Token"},wip:!1},{name:"Azure AD",logo:"/_static/icons/azure.svg",saml:"azure",samlModalCopy:"App Federation Metadata URL",scim:"azure-scim-v2",scimModalCopy:{url:"Tenant URL",token:"Secret Token"},wip:!1},{name:"Google",logo:"/_static/icons/google.svg",saml:"google",samlModalCopy:"XML Metadata File",scim:"google",scimModalCopy:{url:"SCIM 2.0 Base URL",token:"OAuth Bearer Token"},wip:!1}];export{e as a,s as b,p as c,a as d,n as e,c as f,i as g,r as h,l as i,d as j,u as k,_ as l,h as m,E as n,g as o,A as p,I as q,L as r,N as s,m as t,O as u,S as v,T as w,b as x,x as y,w as z,M as A};
@@ -0,0 +1 @@
1
+ var e={city:"San Francisco",region:"CA",country:"US",latitude:"37.7695",longitude:"-122.385"},s="63.141.57.109",p={hidden:{scale:.8,opacity:0},show:{scale:1,opacity:1,transition:{type:"spring"}}},a={hidden:{opacity:0,y:20},show:{opacity:1,y:0,transition:{duration:.4,type:"spring"}}},n={initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.15,ease:"easeOut"}},c={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2}},i=100,r="https://dub.co",l=new Set(["app.dub.co","preview.dub.co","localhost:8888","localhost"]),d=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://app.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://preview.dub.co":"http://localhost:8888",u=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://app.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://preview.dub.co":process.env.NGROK_URL,_=new Set(["api.dub.co","api.dub.sh","api.localhost:8888"]),h=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://api.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://api.dub.sh":"http://api.localhost:8888",E=new Set(["admin.dub.co","admin.localhost:8888"]),g={home:"https://dub.co",dub:"https://dub.co",signin:"https://app.dub.co/login",login:"https://app.dub.co/login",register:"https://app.dub.co/register",signup:"https://app.dub.co/register",app:"https://app.dub.co",dashboard:"https://app.dub.co",links:"https://app.dub.co/links",settings:"https://app.dub.co/settings",welcome:"https://app.dub.co/welcome",discord:"https://twitter.com/dubdotco",tags:"https://dub.co/help/how-to-use-tags"},A={headers:{"x-powered-by":"Dub.co - Link management for modern marketing teams"}},I="/_static/favicons",L="https://www.google.com/s2/favicons?sz=64&domain_url=",N="https://d2vwwcvoksz7ty.cloudfront.net/logo.png",m="https://d2vwwcvoksz7ty.cloudfront.net/thumbnail.png",O=["tools","pricing","help","features","customers","blog","(blog-post)","login","register","auth"],S=[{name:"Metatags API",slug:"metatags"},{name:"Link Inspector",slug:"inspector"}],T=new Set(["com","co","net","org","edu","gov","in"]),b=new Set(["my.id","github.io","vercel.app","now.sh","pages.dev","webflow.io","netlify.app","fly.dev","web.app"]),w={key:"",url:"",domain:"",archived:!1,expiresAt:null,password:null,title:null,description:null,image:null,rewrite:!1,ios:null,android:null,clicks:0,userId:"",proxy:!1},x="cl7pj5kq4006835rbjlt2ofka",M=[{name:"Okta",logo:"/_static/icons/okta.svg",saml:"okta",samlModalCopy:"Metadata URL",scim:"okta-scim-v2",scimModalCopy:{url:"SCIM 2.0 Base URL",token:"OAuth Bearer Token"},wip:!1},{name:"Azure AD",logo:"/_static/icons/azure.svg",saml:"azure",samlModalCopy:"App Federation Metadata URL",scim:"azure-scim-v2",scimModalCopy:{url:"Tenant URL",token:"Secret Token"},wip:!1},{name:"Google",logo:"/_static/icons/google.svg",saml:"google",samlModalCopy:"XML Metadata File",scim:"google",scimModalCopy:{url:"SCIM 2.0 Base URL",token:"OAuth Bearer Token"},wip:!1}];export{e as a,s as b,p as c,a as d,n as e,c as f,i as g,r as h,l as i,d as j,u as k,_ as l,h as m,E as n,g as o,A as p,I as q,L as r,N as s,m as t,O as u,S as v,T as w,b as x,w as y,x as z,M as A};
@@ -0,0 +1 @@
1
+ var t=[{display:"Last hour",value:"1h"},{display:"Last 24 hours",value:"24h"},{display:"Last 7 days",value:"7d"},{display:"Last 30 days",value:"30d"},{display:"Last 3 months",value:"90d"},{display:"All Time",value:"all"}],r={"1h":{startDate:new Date(Date.now()-36e5),granularity:"minute"},"24h":{startDate:new Date(Date.now()-864e5),granularity:"hour"},"7d":{startDate:new Date(Date.now()-6048e5),granularity:"day"},"30d":{startDate:new Date(Date.now()-2592e6),granularity:"day"},"90d":{startDate:new Date(Date.now()-7776e6),granularity:"month"},all:{startDate:new Date("2022-09-22"),granularity:"month"}},n=e=>e?e.includes("curl")?"Curl Request":e.includes("Slackbot")?"Slack Bot":e.includes("Twitterbot")?"Twitter Bot":e.includes("facebookexternalhit")?"Facebook Bot":e.includes("LinkedInBot")?"LinkedIn Bot":e.includes("WhatsApp")?"WhatsApp Bot":e.includes("TelegramBot")?"Telegram Bot":e.includes("Discordbot")?"Discord Bot":e.includes("Googlebot")?"Google Bot":e.includes("Baiduspider")?"Baidu Bot":e.includes("bingbot")?"Bing Bot":e.includes("YandexBot")?"Yandex Bot":e.includes("DuckDuckBot")?"DuckDuckGo Bot":"Unknown Bot":"Unknown Bot";export{t as a,r as b,n as c};
@@ -0,0 +1 @@
1
+ var e={city:"San Francisco",region:"CA",country:"US",latitude:"37.7695",longitude:"-122.385"},s="63.141.57.109",p={hidden:{scale:.8,opacity:0},show:{scale:1,opacity:1,transition:{type:"spring"}}},a={hidden:{opacity:0,y:20},show:{opacity:1,y:0,transition:{duration:.4,type:"spring"}}},n={initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.15,ease:"easeOut"}},c={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2}},i=100,r="https://dub.co",l=new Set(["app.dub.co","preview.dub.co","localhost:8888","localhost"]),d=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"||process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://app.dub.co":"http://localhost:8888",u=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://app.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://preview.dub.co":process.env.NGROK_URL,_=new Set(["api.dub.co","api.dub.sh","api.localhost:8888"]),h=process.env.NEXT_PUBLIC_VERCEL_ENV==="production"?"https://api.dub.co":process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"?"https://api.dub.sh":"http://api.localhost:8888",E=new Set(["admin.dub.co","admin.localhost:8888"]),g={home:"https://dub.co",dub:"https://dub.co",signin:"https://app.dub.co/login",login:"https://app.dub.co/login",register:"https://app.dub.co/register",signup:"https://app.dub.co/register",app:"https://app.dub.co",dashboard:"https://app.dub.co",links:"https://app.dub.co/links",settings:"https://app.dub.co/settings",welcome:"https://app.dub.co/welcome",discord:"https://twitter.com/dubdotco",tags:"https://dub.co/help/how-to-use-tags"},A={headers:{"x-powered-by":"Dub.co - Link management for modern marketing teams"}},I="/_static/favicons",L="https://www.google.com/s2/favicons?sz=64&domain_url=",m="https://d2vwwcvoksz7ty.cloudfront.net/logo.png",N="https://d2vwwcvoksz7ty.cloudfront.net/thumbnail.png",O=["tools","pricing","help","features","customers","blog","(blog-post)","login","register","auth"],S=[{name:"Metatags API",slug:"metatags"},{name:"Link Inspector",slug:"inspector"}],T=new Set(["com","co","net","org","edu","gov","in"]),b=new Set(["my.id","github.io","vercel.app","now.sh","pages.dev","webflow.io","netlify.app","fly.dev","web.app"]),x={key:"",url:"",domain:"",archived:!1,expiresAt:null,password:null,title:null,description:null,image:null,rewrite:!1,ios:null,android:null,clicks:0,userId:"",proxy:!1},w="cl7pj5kq4006835rbjlt2ofka",M=[{name:"Okta",logo:"/_static/icons/okta.svg",saml:"okta",samlModalCopy:"Metadata URL",scim:"okta-scim-v2",scimModalCopy:{url:"SCIM 2.0 Base URL",token:"OAuth Bearer Token"},wip:!1},{name:"Azure AD",logo:"/_static/icons/azure.svg",saml:"azure",samlModalCopy:"App Federation Metadata URL",scim:"azure-scim-v2",scimModalCopy:{url:"Tenant URL",token:"Secret Token"},wip:!1},{name:"Google",logo:"/_static/icons/google.svg",saml:"google",samlModalCopy:"XML Metadata File",scim:"google",scimModalCopy:{url:"SCIM 2.0 Base URL",token:"OAuth Bearer Token"},wip:!1}];export{e as a,s as b,p as c,a as d,n as e,c as f,i as g,r as h,l as i,d as j,u as k,_ as l,h as m,E as n,g as o,A as p,I as q,L as r,m as s,N as t,O as u,S as v,T as w,b as x,x as y,w as z,M as A};
@@ -1 +1 @@
1
- import{A as C,a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r,q as s,r as t,s as u,t as v,u as w,v as x,w as y,x as z,y as A,z as B}from"../chunk-6ES23EVP.mjs";import{a}from"../chunk-MODISIUH.mjs";import{a as b}from"../chunk-3P54C65P.mjs";export{p as ADMIN_HOSTNAMES,x as ALL_TOOLS,o as API_DOMAIN,n as API_HOSTNAMES,l as APP_DOMAIN,m as APP_DOMAIN_WITH_NGROK,k as APP_HOSTNAMES,b as COUNTRIES,A as DEFAULT_LINK_PROPS,q as DEFAULT_REDIRECTS,r as DUB_HEADERS,u as DUB_LOGO,B as DUB_PROJECT_ID,v as DUB_THUMBNAIL,h as FADE_IN_ANIMATION_SETTINGS,s as FAVICON_FOLDER,e as FRAMER_MOTION_LIST_ITEM_VARIANTS,t as GOOGLE_FAVICON_URL,j as HOME_DOMAIN,c as LOCALHOST_GEO_DATA,d as LOCALHOST_IP,i as PAGINATION_LIMIT,C as SAML_PROVIDERS,y as SECOND_LEVEL_DOMAINS,w as SHOW_BACKGROUND_SEGMENTS,z as SPECIAL_APEX_DOMAINS,f as STAGGER_CHILD_VARIANTS,g as SWIPE_REVEAL_ANIMATION_SETTINGS,a as ccTLDs};
1
+ import{A as C,a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r,q as s,r as t,s as u,t as v,u as w,v as x,w as y,x as z,y as A,z as B}from"../chunk-FN35CKKS.mjs";import{a}from"../chunk-MODISIUH.mjs";import{a as b}from"../chunk-3P54C65P.mjs";export{p as ADMIN_HOSTNAMES,x as ALL_TOOLS,o as API_DOMAIN,n as API_HOSTNAMES,l as APP_DOMAIN,m as APP_DOMAIN_WITH_NGROK,k as APP_HOSTNAMES,b as COUNTRIES,A as DEFAULT_LINK_PROPS,q as DEFAULT_REDIRECTS,r as DUB_HEADERS,u as DUB_LOGO,B as DUB_PROJECT_ID,v as DUB_THUMBNAIL,h as FADE_IN_ANIMATION_SETTINGS,s as FAVICON_FOLDER,e as FRAMER_MOTION_LIST_ITEM_VARIANTS,t as GOOGLE_FAVICON_URL,j as HOME_DOMAIN,c as LOCALHOST_GEO_DATA,d as LOCALHOST_IP,i as PAGINATION_LIMIT,C as SAML_PROVIDERS,y as SECOND_LEVEL_DOMAINS,w as SHOW_BACKGROUND_SEGMENTS,z as SPECIAL_APEX_DOMAINS,f as STAGGER_CHILD_VARIANTS,g as SWIPE_REVEAL_ANIMATION_SETTINGS,a as ccTLDs};
@@ -0,0 +1,36 @@
1
+ type IntervalProps = "1h" | "24h" | "7d" | "30d" | "90d" | "all";
2
+ declare const INTERVALS: {
3
+ display: string;
4
+ value: string;
5
+ }[];
6
+ declare const intervalData: {
7
+ "1h": {
8
+ startDate: Date;
9
+ granularity: string;
10
+ };
11
+ "24h": {
12
+ startDate: Date;
13
+ granularity: string;
14
+ };
15
+ "7d": {
16
+ startDate: Date;
17
+ granularity: string;
18
+ };
19
+ "30d": {
20
+ startDate: Date;
21
+ granularity: string;
22
+ };
23
+ "90d": {
24
+ startDate: Date;
25
+ granularity: string;
26
+ };
27
+ all: {
28
+ startDate: Date;
29
+ granularity: string;
30
+ };
31
+ };
32
+ type LocationTabs = "country" | "city" | "region";
33
+ type DeviceTabs = "device" | "browser" | "os" | "bot" | "ua";
34
+ declare const uaToBot: (ua: string) => string;
35
+
36
+ export { DeviceTabs, INTERVALS, IntervalProps, LocationTabs, intervalData, uaToBot };
@@ -0,0 +1 @@
1
+ import{a,b,c}from"../chunk-RKOLFBB4.mjs";export{a as INTERVALS,b as intervalData,c as uaToBot};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  import { Metadata } from 'next';
3
- import { NextRouter } from 'next/router';
3
+ import { ReadonlyURLSearchParams } from 'next/navigation';
4
4
  export { ADMIN_HOSTNAMES, ALL_TOOLS, API_DOMAIN, API_HOSTNAMES, APP_DOMAIN, APP_DOMAIN_WITH_NGROK, APP_HOSTNAMES, DEFAULT_LINK_PROPS, DEFAULT_REDIRECTS, DUB_HEADERS, DUB_LOGO, DUB_PROJECT_ID, DUB_THUMBNAIL, FADE_IN_ANIMATION_SETTINGS, FAVICON_FOLDER, FRAMER_MOTION_LIST_ITEM_VARIANTS, GOOGLE_FAVICON_URL, HOME_DOMAIN, LOCALHOST_GEO_DATA, LOCALHOST_IP, PAGINATION_LIMIT, SAML_PROVIDERS, SECOND_LEVEL_DOMAINS, SHOW_BACKGROUND_SEGMENTS, SPECIAL_APEX_DOMAINS, STAGGER_CHILD_VARIANTS, SWIPE_REVEAL_ANIMATION_SETTINGS } from './constants/index.js';
5
5
  export { default as ccTLDs } from './constants/cctlds.js';
6
6
  export { default as COUNTRIES } from './constants/countries.js';
@@ -21,9 +21,9 @@ declare function nFormatter(num?: number, opts?: {
21
21
  }): string;
22
22
  declare function capitalize(str: string): string;
23
23
  declare const chunk: <T>(array: T[], chunk_size: number) => T[][];
24
- declare function linkConstructor({ key, domain, localhost, pretty, noDomain, }: {
25
- key: string;
24
+ declare function linkConstructor({ domain, key, localhost, pretty, noDomain, }: {
26
25
  domain?: string;
26
+ key?: string;
27
27
  localhost?: boolean;
28
28
  pretty?: boolean;
29
29
  noDomain?: boolean;
@@ -48,12 +48,11 @@ declare const getApexDomain: (url: string) => string;
48
48
  declare const isValidUrl: (url: string) => boolean;
49
49
  declare const getUrlFromString: (str: string) => string | null | undefined;
50
50
  declare const getDomainWithoutWWW: (url: string) => string | null | undefined;
51
- declare const getQueryString: (router: NextRouter, opts?: Record<string, string>) => string;
52
- declare const setQueryString: ({ router, param, value, }: {
53
- router: NextRouter;
54
- param: string;
55
- value: string;
56
- }) => void;
51
+ declare const getSearchParams: (url: string) => Record<string, string>;
52
+ declare const getQueryString: ({ searchParams, groupBy, }: {
53
+ searchParams: URLSearchParams | ReadonlyURLSearchParams | null;
54
+ groupBy?: "domain" | "tagId" | undefined;
55
+ }) => string;
57
56
  declare const truncate: (str: string | null, length: number) => string | null;
58
57
  declare const getParamsFromURL: (url: string) => Record<string, string>;
59
58
  declare const constructURLFromUTMParams: (url: string, utmParams: Record<string, string>) => string;
@@ -72,4 +71,4 @@ declare const log: ({ message, type, mention, }: {
72
71
  type DeepEqual = (obj1: Record<string, any>, obj2: Record<string, any>) => boolean;
73
72
  declare const deepEqual: DeepEqual;
74
73
 
75
- export { capitalize, chunk, cn, constructMetadata, constructURLFromUTMParams, deepEqual, fetcher, formatDate, generateDomainFromName, generateMD5Hash, getAdjustedBillingCycleStart, getApexDomain, getDateTimeLocal, getDomainWithoutWWW, getFirstAndLastDay, getLastDayOfMonth, getParamsFromURL, getQueryString, getSubdomain, getUrlFromString, getUrlWithoutUTMParams, isValidUrl, linkConstructor, log, nFormatter, nanoid, paramsMetadata, setQueryString, timeAgo, truncate, validDomainRegex, validKeyRegex, validSlugRegex };
74
+ export { capitalize, chunk, cn, constructMetadata, constructURLFromUTMParams, deepEqual, fetcher, formatDate, generateDomainFromName, generateMD5Hash, getAdjustedBillingCycleStart, getApexDomain, getDateTimeLocal, getDomainWithoutWWW, getFirstAndLastDay, getLastDayOfMonth, getParamsFromURL, getQueryString, getSearchParams, getSubdomain, getUrlFromString, getUrlWithoutUTMParams, isValidUrl, linkConstructor, log, nFormatter, nanoid, paramsMetadata, timeAgo, truncate, validDomainRegex, validKeyRegex, validSlugRegex };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{A as j,a as S,b as R,c as U,d as k,e as L,f as v,g as M,h as c,i as O,j as _,k as $,l as T,m as A,n as E,o as F,p as N,q as C,r as q,s as I,t as K,u as P,v as z,w as l,x as u,y as H,z as Z}from"./chunk-6ES23EVP.mjs";import{a}from"./chunk-MODISIUH.mjs";import{a as b}from"./chunk-3P54C65P.mjs";import p from"@sindresorhus/slugify";import{clsx as m}from"clsx";import f from"ms";import{customAlphabet as h}from"nanoid";import{twMerge as y}from"tailwind-merge";function G(...e){return y(m(e))}function X({title:e="Dub - Link Management for Modern Marketing Teams",description:t="Dub is an open-source link management tool for modern marketing teams to create, share, and track short links.",image:r="https://dub.co/_static/thumbnail.png",icons:o="/favicon.ico",noIndex:n=!1}={}){return{title:e,description:t,openGraph:{title:e,description:t,images:[{url:r}]},twitter:{card:"summary_large_image",title:e,description:t,images:[r],creator:"@dubdotco"},icons:o,metadataBase:new URL(c),themeColor:"#FFF",...n&&{robots:{index:!1,follow:!1}}}}var ee=h("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);async function te(e,t){let r=await fetch(e,t);if(!r.ok){let o=await r.text(),n=new Error(o);throw n.status=r.status,n}return r.json()}function re(e,t={digits:1}){if(!e)return"0";if(t.full)return Intl.NumberFormat("en-US").format(e);let r=[{value:1,symbol:""},{value:1e3,symbol:"K"},{value:1e6,symbol:"M"},{value:1e9,symbol:"G"},{value:1e12,symbol:"T"},{value:1e15,symbol:"P"},{value:1e18,symbol:"E"}],o=/\.0+$|(\.[0-9]*[1-9])0+$/;var n=r.slice().reverse().find(function(s){return e>=s.value});return n?(e/n.value).toFixed(t.digits).replace(o,"$1")+n.symbol:"0"}function ne(e){return!e||typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}var oe=(e,t)=>e.reduce((r,o,n)=>{let s=Math.floor(n/t);return r[s]||(r[s]=[]),r[s].push(o),r},[]);function se({key:e,domain:t="dub.sh",localhost:r,pretty:o,noDomain:n}){let s=`${r?"http://home.localhost:8888":`https://${t}`}${e!=="_root"?`/${e}`:""}`;return n?`/${e}`:o?s.replace(/^https?:\/\//,""):s}var ae=(e,{withAgo:t}={})=>{if(!e)return"Never";let r=Date.now()-new Date(e).getTime();return r<1e3?"Just now":r>828e5?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:new Date(e).getFullYear()!==new Date().getFullYear()?"numeric":void 0}):`${f(r)}${t?" ago":""}`},ie=e=>{let t=e?new Date(e):new Date;return t.toString()==="Invalid Date"?"":new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().split(":").slice(0,2).join(":")},ce=e=>new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric",timeZone:"UTC"}),le=e=>{let t=new Date,r=t.getDate(),o=t.getMonth(),n=t.getFullYear();if(r>=e)return{firstDay:new Date(n,o,e),lastDay:new Date(n,o+1,e-1)};{let s=o===0?n-1:n,i=o===0?11:o-1;return{firstDay:new Date(s,i,e),lastDay:new Date(n,o,e-1)}}},d=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()},ue=e=>{let t=d();return e>t?t:e},ge=e=>{let t=p(e,{separator:""});if(t.length<3)return"";if(a.has(t.slice(-2)))return`${t.slice(0,-2)}.${t.slice(-2)}`;let r=t.replace(/[aeiou]/g,"");return r.length>=3&&a.has(r.slice(-2))?`${r.slice(0,-2)}.${r.slice(-2)}`:`${[t,r].reduce((n,s)=>n.length<s.length?n:s)}.to`},pe=new RegExp(/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/),me=new RegExp(/^[0-9A-Za-z\u0080-\uFFFF\/\-]*$/u),fe=new RegExp(/^[a-zA-Z0-9\-]+$/),he=(e,t)=>e===t?null:e.slice(0,e.length-t.length-1),ye=e=>{let t;try{t=new URL(e.replace(/^[a-zA-Z]+:\/\//,"https://")).hostname}catch{return""}if(t==="youtu.be")return"youtube.com";if(t==="raw.githubusercontent.com")return"github.com";if(t.endsWith(".vercel.app"))return"vercel.app";let r=t.split(".");return r.length>2?l.has(r[r.length-2])&&a.has(r[r.length-1])||u.has(r.slice(-2).join("."))?r.slice(-3).join("."):r.slice(-2).join("."):t},g=e=>{try{return new URL(e),!0}catch{return!1}},de=e=>{if(g(e))return e;try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).toString()}catch{return null}},xe=e=>{if(g(e))return new URL(e).hostname.replace(/^www\./,"");try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).hostname.replace(/^www\./,"")}catch{return null}},De=(e,t)=>{let r=new URLSearchParams({...e.query,...t}).toString();return`${r?"?":""}${r}`},we=({router:e,param:t,value:r})=>{t!=="page"&&delete e.query.page;let o;r.length>0?o={...e.query,[t]:r}:(delete e.query[t],o={...e.query});let{slug:n,...s}=o;e.replace({pathname:`/${e.query.slug||"links"}`,query:s})},be=(e,t)=>!e||e.length<=t?e:`${e.slice(0,t-3)}...`,Se=e=>{if(!e)return{};try{let t=new URL(e).searchParams,r={};for(let[o,n]of t.entries())n&&n!==""&&(r[o]=n);return r}catch{return{}}},Re=(e,t)=>{if(!e)return"";try{let r=new URL(e);for(let[o,n]of Object.entries(t))n===""?r.searchParams.delete(o):r.searchParams.set(o,n);return r.toString()}catch{return""}},x=[{display:"Referral (ref)",key:"ref",examples:"twitter, facebook"},{display:"UTM Source",key:"utm_source",examples:"twitter, facebook"},{display:"UTM Medium",key:"utm_medium",examples:"social, email"},{display:"UTM Campaign",key:"utm_campaign",examples:"summer_sale"},{display:"UTM Term",key:"utm_term",examples:"blue_shoes"},{display:"UTM Content",key:"utm_content",examples:"logolink"}],Ue=e=>{try{let t=new URL(e);return x.forEach(r=>t.searchParams.delete(r.key)),t.toString()}catch{return e}};async function ke(e){let r=new TextEncoder().encode(e),o=await crypto.subtle.digest("MD5",r);return Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join("")}var D={cron:process.env.DUB_SLACK_HOOK_CRON,links:process.env.DUB_SLACK_HOOK_LINKS},Le=async({message:e,type:t,mention:r=!1})=>{(process.env.NODE_ENV==="development"||!process.env.DUB_SLACK_HOOK_CRON||!process.env.DUB_SLACK_HOOK_LINKS)&&console.log(e);let o=D[t];if(!!o)try{return await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blocks:[{type:"section",text:{type:"mrkdwn",text:`${r?"<@U0404G6J3NJ> ":""}${e}`}}]})})}catch(n){console.log(`Failed to log to Dub Slack. Error: ${n}`)}},w=(e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let n of r)if(!o.includes(n)||!w(e[n],t[n]))return!1;return!0};export{E as ADMIN_HOSTNAMES,z as ALL_TOOLS,A as API_DOMAIN,T as API_HOSTNAMES,_ as APP_DOMAIN,$ as APP_DOMAIN_WITH_NGROK,O as APP_HOSTNAMES,b as COUNTRIES,H as DEFAULT_LINK_PROPS,F as DEFAULT_REDIRECTS,N as DUB_HEADERS,I as DUB_LOGO,Z as DUB_PROJECT_ID,K as DUB_THUMBNAIL,v as FADE_IN_ANIMATION_SETTINGS,C as FAVICON_FOLDER,U as FRAMER_MOTION_LIST_ITEM_VARIANTS,q as GOOGLE_FAVICON_URL,c as HOME_DOMAIN,S as LOCALHOST_GEO_DATA,R as LOCALHOST_IP,M as PAGINATION_LIMIT,j as SAML_PROVIDERS,l as SECOND_LEVEL_DOMAINS,P as SHOW_BACKGROUND_SEGMENTS,u as SPECIAL_APEX_DOMAINS,k as STAGGER_CHILD_VARIANTS,L as SWIPE_REVEAL_ANIMATION_SETTINGS,ne as capitalize,a as ccTLDs,oe as chunk,G as cn,X as constructMetadata,Re as constructURLFromUTMParams,w as deepEqual,te as fetcher,ce as formatDate,ge as generateDomainFromName,ke as generateMD5Hash,ue as getAdjustedBillingCycleStart,ye as getApexDomain,ie as getDateTimeLocal,xe as getDomainWithoutWWW,le as getFirstAndLastDay,d as getLastDayOfMonth,Se as getParamsFromURL,De as getQueryString,he as getSubdomain,de as getUrlFromString,Ue as getUrlWithoutUTMParams,g as isValidUrl,se as linkConstructor,Le as log,re as nFormatter,ee as nanoid,x as paramsMetadata,we as setQueryString,ae as timeAgo,be as truncate,pe as validDomainRegex,me as validKeyRegex,fe as validSlugRegex};
1
+ import{A as B,a as b,b as U,c as R,d as L,e as k,f as v,g as M,h as c,i as O,j as _,k as T,l as $,m as A,n as E,o as F,p as N,q as C,r as P,s as I,t as K,u as z,v as H,w as l,x as u,y as Z,z as j}from"./chunk-FN35CKKS.mjs";import{a as s}from"./chunk-MODISIUH.mjs";import{a as S}from"./chunk-3P54C65P.mjs";import m from"@sindresorhus/slugify";import{clsx as p}from"clsx";import f from"ms";import{customAlphabet as h}from"nanoid";import{twMerge as d}from"tailwind-merge";function Q(...e){return d(p(e))}function X({title:e="Dub - Link Management for Modern Marketing Teams",description:t="Dub is an open-source link management tool for modern marketing teams to create, share, and track short links.",image:r="https://dub.co/_static/thumbnail.png",icons:n="/favicon.ico",noIndex:o=!1}={}){return{title:e,description:t,openGraph:{title:e,description:t,images:[{url:r}]},twitter:{card:"summary_large_image",title:e,description:t,images:[r],creator:"@dubdotco"},icons:n,metadataBase:new URL(c),...o&&{robots:{index:!1,follow:!1}}}}var ee=h("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);async function te(e,t){let r=await fetch(e,t);if(!r.ok){let n=await r.text(),o=new Error(n);throw o.status=r.status,o}return r.json()}function re(e,t={digits:1}){if(!e)return"0";if(t.full)return Intl.NumberFormat("en-US").format(e);let r=[{value:1,symbol:""},{value:1e3,symbol:"K"},{value:1e6,symbol:"M"},{value:1e9,symbol:"G"},{value:1e12,symbol:"T"},{value:1e15,symbol:"P"},{value:1e18,symbol:"E"}],n=/\.0+$|(\.[0-9]*[1-9])0+$/;var o=r.slice().reverse().find(function(a){return e>=a.value});return o?(e/o.value).toFixed(t.digits).replace(n,"$1")+o.symbol:"0"}function ne(e){return!e||typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}var oe=(e,t)=>e.reduce((r,n,o)=>{let a=Math.floor(o/t);return r[a]||(r[a]=[]),r[a].push(n),r},[]);function ae({domain:e="dub.sh",key:t,localhost:r,pretty:n,noDomain:o}){let a=`${r?"http://home.localhost:8888":`https://${e}`}${t&&t!=="_root"?`/${t}`:""}`;return o?`/${t}`:n?a.replace(/^https?:\/\//,""):a}var se=(e,{withAgo:t}={})=>{if(!e)return"Never";let r=Date.now()-new Date(e).getTime();return r<1e3?"Just now":r>828e5?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:new Date(e).getFullYear()!==new Date().getFullYear()?"numeric":void 0}):`${f(r)}${t?" ago":""}`},ie=e=>{let t=e?new Date(e):new Date;return t.toString()==="Invalid Date"?"":new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().split(":").slice(0,2).join(":")},ce=e=>new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric",timeZone:"UTC"}),le=e=>{let t=new Date,r=t.getDate(),n=t.getMonth(),o=t.getFullYear();if(r>=e)return{firstDay:new Date(o,n,e),lastDay:new Date(o,n+1,e-1)};{let a=n===0?o-1:o,i=n===0?11:n-1;return{firstDay:new Date(a,i,e),lastDay:new Date(o,n,e-1)}}},y=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()},ue=e=>{let t=y();return e>t?t:e},ge=e=>{let t=m(e,{separator:""});if(t.length<3)return"";if(s.has(t.slice(-2)))return`${t.slice(0,-2)}.${t.slice(-2)}`;let r=t.replace(/[aeiou]/g,"");return r.length>=3&&s.has(r.slice(-2))?`${r.slice(0,-2)}.${r.slice(-2)}`:`${[t,r].reduce((o,a)=>o.length<a.length?o:a)}.to`},me=new RegExp(/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/),pe=new RegExp(/^[0-9A-Za-z\u0080-\uFFFF\/\-]*$/u),fe=new RegExp(/^[a-zA-Z0-9\-]+$/),he=(e,t)=>e===t?null:e.slice(0,e.length-t.length-1),de=e=>{let t;try{t=new URL(e.replace(/^[a-zA-Z]+:\/\//,"https://")).hostname}catch{return""}if(t==="youtu.be")return"youtube.com";if(t==="raw.githubusercontent.com")return"github.com";if(t.endsWith(".vercel.app"))return"vercel.app";let r=t.split(".");return r.length>2?l.has(r[r.length-2])&&s.has(r[r.length-1])||u.has(r.slice(-2).join("."))?r.slice(-3).join("."):r.slice(-2).join("."):t},g=e=>{try{return new URL(e),!0}catch{return!1}},ye=e=>{if(g(e))return e;try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).toString()}catch{return null}},xe=e=>{if(g(e))return new URL(e).hostname.replace(/^www\./,"");try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).hostname.replace(/^www\./,"")}catch{return null}},we=e=>{let t={};return new URL(e).searchParams.forEach(function(r,n){t[n]=r}),t},De=({searchParams:e,groupBy:t})=>{let r=new URLSearchParams(e==null?void 0:e.toString());t&&r.set("groupBy",t);let n=r.toString();return n.length>0?`?${n}`:""},Se=(e,t)=>!e||e.length<=t?e:`${e.slice(0,t-3)}...`,be=e=>{if(!e)return{};try{let t=new URL(e).searchParams,r={};for(let[n,o]of t.entries())o&&o!==""&&(r[n]=o);return r}catch{return{}}},Ue=(e,t)=>{if(!e)return"";try{let r=new URL(e);for(let[n,o]of Object.entries(t))o===""?r.searchParams.delete(n):r.searchParams.set(n,o);return r.toString()}catch{return""}},x=[{display:"Referral (ref)",key:"ref",examples:"twitter, facebook"},{display:"UTM Source",key:"utm_source",examples:"twitter, facebook"},{display:"UTM Medium",key:"utm_medium",examples:"social, email"},{display:"UTM Campaign",key:"utm_campaign",examples:"summer_sale"},{display:"UTM Term",key:"utm_term",examples:"blue_shoes"},{display:"UTM Content",key:"utm_content",examples:"logolink"}],Re=e=>{try{let t=new URL(e);return x.forEach(r=>t.searchParams.delete(r.key)),t.toString()}catch{return e}};async function Le(e){let r=new TextEncoder().encode(e),n=await crypto.subtle.digest("MD5",r);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}var w={cron:process.env.DUB_SLACK_HOOK_CRON,links:process.env.DUB_SLACK_HOOK_LINKS},ke=async({message:e,type:t,mention:r=!1})=>{(process.env.NODE_ENV==="development"||!process.env.DUB_SLACK_HOOK_CRON||!process.env.DUB_SLACK_HOOK_LINKS)&&console.log(e);let n=w[t];if(!!n)try{return await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blocks:[{type:"section",text:{type:"mrkdwn",text:`${r?"<@U0404G6J3NJ> ":""}${e}`}}]})})}catch(o){console.log(`Failed to log to Dub Slack. Error: ${o}`)}},D=(e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!n.includes(o)||!D(e[o],t[o]))return!1;return!0};export{E as ADMIN_HOSTNAMES,H as ALL_TOOLS,A as API_DOMAIN,$ as API_HOSTNAMES,_ as APP_DOMAIN,T as APP_DOMAIN_WITH_NGROK,O as APP_HOSTNAMES,S as COUNTRIES,Z as DEFAULT_LINK_PROPS,F as DEFAULT_REDIRECTS,N as DUB_HEADERS,I as DUB_LOGO,j as DUB_PROJECT_ID,K as DUB_THUMBNAIL,v as FADE_IN_ANIMATION_SETTINGS,C as FAVICON_FOLDER,R as FRAMER_MOTION_LIST_ITEM_VARIANTS,P as GOOGLE_FAVICON_URL,c as HOME_DOMAIN,b as LOCALHOST_GEO_DATA,U as LOCALHOST_IP,M as PAGINATION_LIMIT,B as SAML_PROVIDERS,l as SECOND_LEVEL_DOMAINS,z as SHOW_BACKGROUND_SEGMENTS,u as SPECIAL_APEX_DOMAINS,L as STAGGER_CHILD_VARIANTS,k as SWIPE_REVEAL_ANIMATION_SETTINGS,ne as capitalize,s as ccTLDs,oe as chunk,Q as cn,X as constructMetadata,Ue as constructURLFromUTMParams,D as deepEqual,te as fetcher,ce as formatDate,ge as generateDomainFromName,Le as generateMD5Hash,ue as getAdjustedBillingCycleStart,de as getApexDomain,ie as getDateTimeLocal,xe as getDomainWithoutWWW,le as getFirstAndLastDay,y as getLastDayOfMonth,be as getParamsFromURL,De as getQueryString,we as getSearchParams,he as getSubdomain,ye as getUrlFromString,Re as getUrlWithoutUTMParams,g as isValidUrl,ae as linkConstructor,ke as log,re as nFormatter,ee as nanoid,x as paramsMetadata,se as timeAgo,Se as truncate,me as validDomainRegex,pe as validKeyRegex,fe as validSlugRegex};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dub/utils",
3
3
  "description": "Utility functions and constants for Dub.co",
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",