Skip to content

Commit

Permalink
fix: handle optional pathname in StyledLink component
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Koech authored and Kevin Koech committed Feb 4, 2025
1 parent e1171fd commit d003155
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/commons-ui-next/src/Link/StyledLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const StyledLink = React.forwardRef(function Link(props, ref) {
} = props;

// https://nextjs.org/docs/app/api-reference/components/link#href-required
const url = typeof href === "string" ? href : href.pathname;
const url = typeof href === "string" ? href : href?.pathname;
const isExternal = isExternalUrl(url);
if (isExternal) {
const externalLinkProps = {
Expand Down Expand Up @@ -117,7 +117,7 @@ const StyledLink = React.forwardRef(function Link(props, ref) {
StyledLink.propTypes = {
as: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
className: PropTypes.string,
href: PropTypes.string,
href: PropTypes.string.isRequired,
legacyBehavior: PropTypes.bool,
linkAs: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
locale: PropTypes.string,
Expand Down

0 comments on commit d003155

Please sign in to comment.