Skip to content

Commit

Permalink
fix(BacktraceLine.tsx): handle case where fileUrl is null or undefine…
Browse files Browse the repository at this point in the history
…d by rendering a span instead of a link

fix(gitProvider.ts): return empty string instead of '#' when url is not defined in default case of switch statement
  • Loading branch information
masterkain committed May 29, 2023
1 parent 6a0c833 commit 3ddbef7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/occurrence/BacktraceLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ export default function LinkedBacktraceLine({ file, line, project }: { file: str
const filePath = file.replace('/PROJECT_ROOT/', '');
const fileUrl = composeFileUrl(project, filePath, line);

return (
return fileUrl ? (
<a href={fileUrl} target="_blank" rel="noopener noreferrer" className="text-indigo-400 hover:text-indigo-200">
{file}
</a>
) : (
<span className="text-indigo-400">{file}</span>
);
} else {
return <>{file}</>;
Expand Down
5 changes: 4 additions & 1 deletion lib/gitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export function composeFileUrl(
const repoUrl = project.repo_url?.toLowerCase() || '';
const repoBranch = project.repo_branch?.toLowerCase() || '';
const filePathLower = filePath.toLowerCase();
if (!repoUrl || !repoBranch || !filePathLower) {
return '';
}

let url: string;

Expand Down Expand Up @@ -55,7 +58,7 @@ export function composeFileUrl(
}
break;
default:
url = '#';
url = '';
break;
}

Expand Down

0 comments on commit 3ddbef7

Please sign in to comment.