Skip to content

Commit 81d37a9

Browse files
update getUrlHostname function to remove www
1 parent f4fae46 commit 81d37a9

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@curiousleaf/utils",
33
"description": "A lightweight set of utilities",
4-
"version": "1.0.36",
4+
"version": "1.0.37",
55
"license": "MIT",
66
"author": {
77
"name": "Piotr Kulpinski",

src/http/http.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ export const isExternalLink = (url?: string): boolean => {
4545
* @param url The URL to be stripped.
4646
* @returns The URL with the subpath removed.
4747
*/
48-
export const stripURLSubpath = (url?: string) => {
49-
if (!url) return url
50-
48+
export const stripURLSubpath = (url: string) => {
5149
try {
5250
const parsedUrl = new URL(url)
5351
return `${parsedUrl.protocol}//${parsedUrl.host}`
@@ -64,7 +62,7 @@ export const stripURLSubpath = (url?: string) => {
6462
*/
6563
export const getUrlHostname = (url: string) => {
6664
if (isValidUrl(url)) {
67-
return new URL(url).hostname
65+
return new URL(url).hostname.replace("www.", "")
6866
}
6967

7068
return url

0 commit comments

Comments
 (0)