Sitecore / jss

Software development kit for JavaScript developers building web applications with Sitecore Experience Platform
https://jss.sitecore.com
Apache License 2.0
261 stars 272 forks source link

NextJS internalLinkMatcher default matches media URLs which causes issues with query strings #1654

Open mg-aceik opened 10 months ago

mg-aceik commented 10 months ago

Describe the Bug

The internalLinkMatcher default matches media URLs which causes issues with query strings https://github.com/Sitecore/jss/blob/d4bc9e9c9ff9fa4a530950aa23ae854f1da16ea3/packages/sitecore-jss-nextjs/src/components/Link.tsx#L26

To Reproduce

  import {
    Link as JssLink,
  } from '@sitecore-jss/sitecore-jss-nextjs';
  <JssLink field={field}  />

Set the field to be a media link with query params.

Expected Behavior

Logic should not be calling down to NextLink, but it is.

Possible Fix

const internalLinkMatcher = /^\/(?!(-\/media|-\/jssmedia))/;

Provide environment information

illiakovalenko commented 9 months ago

@mg-aceik Thank you for submitting your contribution! I've added a ticket containing all the details. It has been added to our internal backlog for thorough review