Skip to content

Commit

Permalink
pageContext.urlParsed.host
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Jul 19, 2024
1 parent 74aaa14 commit 24925b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vike/shared/getPageContextUrlComputed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type Url = {
hrefOriginal: null | string
/** The URL protocol, e.g. `https://` in `https://example.com` */
protocol: null | string
/** The URL host, e.g. `example.com` in `https://example.com/product` */
host: null | string
/** The URL origin, e.g. `https://example.com` in `https://example.com/product/42?details=yes#reviews` */
origin: null | string
/** The URL pathname, e.g. `/product/42` in `https://example.com/product/42?details=yes#reviews` */
Expand Down
3 changes: 3 additions & 0 deletions vike/utils/parseUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function parseUrl(
href: string
hrefOriginal: string
protocol: null | string
host: null | string
origin: null | string
pathname: string
pathnameOriginal: string
Expand Down Expand Up @@ -80,12 +81,14 @@ function parseUrl(

const href = createUrlFromComponents(origin, pathname, searchOriginal, hashOriginal)
const hrefOriginal = createUrlFromComponents(origin, pathnameOriginal, searchOriginal, hashOriginal)
const host = !origin ? null : origin.slice(protocol!.length)

assert(pathname.startsWith('/'))
return {
href,
hrefOriginal,
protocol,
host,
origin,
pathname,
pathnameOriginal: pathnameOriginal,
Expand Down

0 comments on commit 24925b9

Please sign in to comment.