noaignite / create-ignite-app

Boilerplate for React with Next.js and MUI
17 stars 2 forks source link

Update RegEx in RouterLink for www #86

Closed axelpahne closed 1 year ago

axelpahne commented 1 year ago

In the RouterLink component... The current RegEx does not have support for www so it does not set thoes links as external

  // Render as a regular `a` tag if external link.
  if (external || /^https?:\/\//.test(href)) {
    return (
      <a href={href} rel="noopener noreferrer" target="_blank" ref={ref} {...other}>
        {children}
      </a>
    )
  }
maeertin commented 1 year ago

Thank you @axelpahne for the issue ✨ What's your thoughts here @alexanderflink?

alexanderflink commented 1 year ago

Apparently, <a> tags in HTML that do not have protocol (e.g www.google.com) are actually interpreted as relative links by the browser. So we should not fix this as it is expected behaviour. We could possibly add validation in the cms that adds the protocol if the user enters "www".