getEndpointUrl
Script
v4
Fork
1
2
3
4
5
6
7
8
9
10
11
/**
* Function to extract the val HTTP endpoint URL.
* @example getEndpointUrl(import.meta.url)
* @returns endpoint url without a trailing slash
*/
export
function
getEndpointUrl
(
url
:
string
|
URL
)
{
const
{
pathname
}
=
new
URL
(
url
)
;
const
[
author
,
filename
]
=
pathname
.
split
(
'/'
)
.
slice
(
-
2
)
;
const
[
name
]
=
filename
.
split
(
'.'
)
;
return
`https://
${
author
}
-
${
name
}
.web.val.run`
;
}