Skip to content

Commit

Permalink
Merge branch 'main' into pr/multiple-docmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed May 7, 2024
2 parents 160accd + 5cc1455 commit 5c37993
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/RelativeLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const PrimaryLink = props => {
);
};

const PROD_DOMAIN = 'https://www.apollographql.com';

function useLinkProps(href) {
const {path} = useContext(PathContext);
const {site} = useStaticQuery(
Expand All @@ -61,21 +63,18 @@ function useLinkProps(href) {
if (process.env.CONTEXT !== 'production') {
// fix up absolute urls pointing to the docs
// for netlify previews and localhost
href = href.replace(
'https://www.apollographql.com/docs',
process.env.DEPLOY_URL
);
href = href.replace(PROD_DOMAIN + '/docs', process.env.DEPLOY_URL);
}

try {
// convert full urls for the current domain into absolute domain-relative urls
const url = new URL(href);
if (
url.host === window.location.host &&
href.startsWith('https://www.apollographql.com/docs/') &&
href.startsWith(PROD_DOMAIN + '/docs') &&
!href.includes('/ios/docc/')
) {
href = url.pathname;
href = href.slice(PROD_DOMAIN.length);
}
} catch {
// it's okay if this fails, then it probably wasn't a full url
Expand All @@ -86,7 +85,7 @@ function useLinkProps(href) {
const isFile = /\.[a-z]+$/.test(href);
if (
isExternal &&
href.startsWith('https://www.apollographql.com/') &&
href.startsWith(PROD_DOMAIN + '/') &&
!href.includes('referrer')
) {
href += href.includes('?')
Expand Down

0 comments on commit 5c37993

Please sign in to comment.