Skip to content

Commit

Permalink
clients/external: make github-sourced links external
Browse files Browse the repository at this point in the history
  • Loading branch information
zegl committed Oct 31, 2023
1 parent 4a43e48 commit b121662
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SubscriptionTier,
} from '@polar-sh/sdk'
import { Avatar } from 'polarkit/components/ui/atoms'
import { prettyURL } from '.'
import { externalURL, prettyURL } from '.'
import HowItWorks from '../Pledge/HowItWorks'
import PublicSubscriptionUpsell from '../Subscriptions/PublicSubscriptionUpsell'
import Footer from './Footer'
Expand Down Expand Up @@ -73,7 +73,7 @@ const OrganizationPublicPage = ({
<LanguageOutlined fontSize="small" />
<a
className="text-blue-600 hover:text-blue-700"
href={organization.blog}
href={externalURL(organization.blog)}
>
{prettyURL(organization.blog)}
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IssueFunding, Organization, Repository } from '@polar-sh/sdk'
import { formatStarsNumber } from 'polarkit/utils'
import { prettyURL } from '.'
import { externalURL, prettyURL } from '.'
import HowItWorks from '../Pledge/HowItWorks'
import Footer from './Footer'
import Header from './Header'
Expand Down Expand Up @@ -48,7 +48,7 @@ const RepositoryPublicPage = ({
{repository.homepage && (
<a
className="text-blue-600 hover:text-blue-700"
href={repository.homepage}
href={externalURL(repository.homepage)}
>
{prettyURL(repository.homepage)}
</a>
Expand Down
16 changes: 16 additions & 0 deletions clients/apps/web/src/components/Organization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@ export const prettyURL = (url: string): string => {
}
return url
}

export const externalURL = (url: string): string => {
if (url.startsWith('http://')) {
return url
}
if (url.startsWith('https://')) {
return url
}
if (url.startsWith('//')) {
return `https:${url}`
}
if (url.startsWith('://')) {
return `https${url}`
}
return `https://${url}`
}

2 comments on commit b121662

@vercel
Copy link

@vercel vercel bot commented on b121662 Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b121662 Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./docs

docs-sigma-puce.vercel.app
docs-polar-sh.vercel.app
docs-git-main-polar-sh.vercel.app
docs.polar.sh

Please sign in to comment.