Skip to content

Commit

Permalink
minor refactor: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Jul 19, 2024
1 parent fbd3354 commit 140097e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions vike/shared/getPageContextUrlComputed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
isPropertyGetter,
isBrowser,
changeEnumerable,
UrlPublic
type UrlPublic
} from './utils.js'

// TODO/v1-release: move pageContext.urlParsed to pageContext.url
Expand Down Expand Up @@ -141,7 +141,11 @@ function urlGetter(this: PageContextUrlSource) {
return urlPathnameGetter.call(this)
}
function urlParsedGetter(this: PageContextUrlSource) {
const { hasBaseServer: _, ...urlParsed } = getUrlParsed(this)
const {
// remove hasBaseServer as it isn't part of UrlPublic
hasBaseServer: _,
...urlParsed
} = getUrlParsed(this)

const hashIsAvailable = isBrowser()
const warnHashNotAvailable = (prop: HashProps) => {
Expand All @@ -162,6 +166,7 @@ function urlParsedGetter(this: PageContextUrlSource) {
warnHashNotAvailable('hashOriginal')
return urlParsed.hashOriginal
},
// TODO/next-major-release: remove
get hashString() {
assertWarning(false, 'pageContext.urlParsed.hashString has been renamed to pageContext.urlParsed.hashOriginal', {
onlyOnce: true,
Expand All @@ -170,6 +175,7 @@ function urlParsedGetter(this: PageContextUrlSource) {
warnHashNotAvailable('hashString')
return urlParsed.hashOriginal
},
// TODO/next-major-release: remove
get searchString() {
assertWarning(
false,
Expand Down
4 changes: 2 additions & 2 deletions vike/utils/parseUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function parseUrl(url: string, baseServer: string): UrlPrivate {
})

// Origin + pathname
let { protocol, origin, pathnameAbsoluteWithBase } = getPathnameWithBase(urlWithoutHashNorSearch, baseServer)
let { protocol, origin, pathnameAbsoluteWithBase } = getPathnameAbsoluteWithBase(urlWithoutHashNorSearch, baseServer)
const pathnameOriginal = urlWithoutHashNorSearch.slice((origin || '').length)
assertUrlComponents(url, origin, pathnameOriginal, searchOriginal, hashOriginal)

Expand Down Expand Up @@ -131,7 +131,7 @@ function decodePathname(urlPathname: string) {
.join('/')
return urlPathname
}
function getPathnameWithBase(
function getPathnameAbsoluteWithBase(
url: string,
baseServer: string
): { origin: null | string; pathnameAbsoluteWithBase: string; protocol: null | string } {
Expand Down

0 comments on commit 140097e

Please sign in to comment.