Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Sep 25, 2023
1 parent 41049d3 commit 0179706
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const mockFetchCdnSettings = (cdnSettings: any = {}) => {
.mockImplementation(createMockFetchImplementation(cdnSettings))
}

// TODO: delete this when remove these methods completely.
const ogConsoleWarn = console.warn
jest.spyOn(console, 'warn').mockImplementation((msg) => {
if (msg.includes('deprecate')) {
Expand Down
32 changes: 17 additions & 15 deletions packages/browser/src/core/page/get-page-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,24 @@ const formatCanonicalPath = (canonicalUrl: string) => {
return a.pathname[0] === '/' ? a.pathname : '/' + a.pathname
}

export const createPageContext = (
buffered: BufferedPageContext
): PageContext => {
const path = buffered.c ? formatCanonicalPath(buffered.c) : buffered.p
const url = buffered.c
? createCanonicalURL(buffered.c, buffered.s)
: removeHash(buffered.u)

// Why are we removing the anchor here but not the canonical URL? Also, why don't we include hash or any anchor arguments. (???)
// There's no way for a customer to get access to hash arguments without overriding url =S
export const createPageContext = ({
c: canonicalUrl,
p: pathname,
s: search,
u: url,
r: referrer,
t: title,
}: BufferedPageContext): PageContext => {
const newPath = canonicalUrl ? formatCanonicalPath(canonicalUrl) : pathname
const newUrl = canonicalUrl
? createCanonicalURL(canonicalUrl, search)
: removeHash(url)
return {
path,
referrer: buffered.r,
search: buffered.s,
title: buffered.t,
url,
path: newPath,
referrer,
search,
title,
url: newUrl,
}
}

Expand Down

0 comments on commit 0179706

Please sign in to comment.