Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion web/src/layout/contributor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { createSignal, JSXElement, Match, onCleanup, onMount, Show, Switch } fro

import API from '../../api';
import clotributor from '../../assets/clotributor.png';
import { useContributorsDataInfo } from '../../stores/contributorsData';
import { ContributionKind, Contributor } from '../../types';
import prettifyNumber from '../../utils/prettifyNumber';
import resolveContributorId from '../../utils/resolveContributorId';
import updateMetaTags from '../../utils/updateMetaTags';
import ExternalLink from '../common/ExternalLink';
import Image from '../common/Image';
Expand Down Expand Up @@ -63,8 +65,11 @@ const ContributionKindIcon = (props: Props): JSXElement => {
const ContributorCard = () => {
const location = useLocation();
const params = useParams();
const contributorsInfo = useContributorsDataInfo();
const [contributor, setContributor] = createSignal<Contributor | null | undefined>();

const resolveId = (id: string): string => resolveContributorId(id, contributorsInfo());

const getFirstContributionLink = () => {
let url = `https://github.com/${contributor()!.first_contribution.owner}/${
contributor()!.first_contribution.repository
Expand Down Expand Up @@ -96,7 +101,7 @@ const ContributorCard = () => {

onMount(() => {
if (contributor() === undefined) {
fecthContributorInfo(params.id);
fecthContributorInfo(resolveId(params.id));
}
updateMetaTags(`${window.location.origin}${location.pathname}`);
});
Expand Down
3 changes: 2 additions & 1 deletion web/src/layout/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useContributorsDataLoader,
} from '../../stores/contributorsData';
import prettifyNumber from '../../utils/prettifyNumber';
import resolveContributorId from '../../utils/resolveContributorId';
import updateMetaTags from '../../utils/updateMetaTags';
import HoverableItem from '../common/HoverableItem';
import Image from '../common/Image';
Expand Down Expand Up @@ -108,7 +109,7 @@ const Search = () => {
cleanItemsSearch();
setValue('');
forceBlur();
navigate(`/${contributorId}`, {
navigate(`/${resolveContributorId(contributorId, contributorsInfo())}`, {
replace: false,
scroll: true, // default
});
Expand Down
12 changes: 12 additions & 0 deletions web/src/utils/resolveContributorId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { UserInfo } from '../types';

const resolveContributorId = (id: string, info: UserInfo | null | undefined): string => {
if (info) {
const lower = id.toLowerCase();
const canonical = Object.keys(info).find((k) => k.toLowerCase() === lower);
if (canonical) return canonical;
}
return id.toLowerCase();
};

export default resolveContributorId;