Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

 #534241: [sitecore-jss-nextjs][middleware-redirect]added handling with token $siteLang #1454

Merged
merged 5 commits into from
Apr 28, 2023

Conversation

sc-ruslanmatkovskyi
Copy link
Collaborator

@sc-ruslanmatkovskyi sc-ruslanmatkovskyi commented Apr 26, 2023

Description / Motivation

Added a new handling for token $siteLang(context site language) in middleware redirect

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@sc-ruslanmatkovskyi sc-ruslanmatkovskyi force-pushed the bugfix/534241-add-token-siteLang-to-redirect branch from cbfb700 to 874845f Compare April 26, 2023 17:42
…middleware redirect.

 added DefaultPlugin for siteResolver
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please check linting, the check is currently failing.

@sc-ruslanmatkovskyi sc-ruslanmatkovskyi force-pushed the bugfix/534241-add-token-siteLang-to-redirect branch from 89a2f36 to dff757a Compare April 27, 2023 22:27
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (approved), but I do have a question about the $siteLang token in general. If the intent is to always replace with the context site's default language, then this satisfies the requirements. However, I imagine it's more useful to replace with the context language (i.e. from NextUrl.locale).

For example, if I have a single site (default language = 'en') with 2 language versions ('en' and 'da-DK') and am using Next.js i18n sub-path routing, I would want to be able to configure a redirect target like:

pattern: /not-found > target: http://mysite.com/$contextLang/found

So that this would be the result:
http://mysite.com/en/not-found >http://mysite.com/en/found
http://mysite.com/da-DK/not-found >http://mysite.com/da-DK/found

With $siteLang, this would be the result:
http://mysite.com/en/not-found >http://mysite.com/en/found
http://mysite.com/da-DK/not-found >http://mysite.com/en/found

@sc-ruslanmatkovskyi
Copy link
Collaborator Author

Looks good (approved), but I do have a question about the $siteLang token in general. If the intent is to always replace with the context site's default language, then this satisfies the requirements. However, I imagine it's more useful to replace with the context language (i.e. from NextUrl.locale).

For example, if I have a single site (default language = 'en') with 2 language versions ('en' and 'da-DK') and am using Next.js i18n sub-path routing, I would want to be able to configure a redirect target like:

pattern: /not-found > target: http://mysite.com/$contextLang/found

So that this would be the result: http://mysite.com/en/not-found >http://mysite.com/en/found http://mysite.com/da-DK/not-found >http://mysite.com/da-DK/found

With $siteLang, this would be the result: http://mysite.com/en/not-found >http://mysite.com/en/found http://mysite.com/da-DK/not-found >http://mysite.com/en/found

Yeah, but in this situation we not use token $siteLang it will work the same without token, right?

@ambrauer
Copy link
Contributor

Yeah, but in this situation we not use token $siteLang it will work the same without token, right?

Oh really? Just to confirm... You're saying that if I have this redirect configured:

pattern: /not-found > target: http://mysite.com/found

then these requests would redirect as follows?
http://mysite.com/en/not-found -> http://mysite.com/en/found
http://mysite.com/da-DK/not-found -> http://mysite.com/da-DK/found

Guess I'm just trying to think of the business value in being able to redirect to the site's configured default language (vs the route's context language).

@sc-ruslanmatkovskyi
Copy link
Collaborator Author

Yeah, but in this situation we not use token $siteLang it will work the same without token, right?

Oh really? Just to confirm... You're saying that if I have this redirect configured:

pattern: /not-found > target: http://mysite.com/found

then these requests would redirect as follows? http://mysite.com/en/not-found -> http://mysite.com/en/found http://mysite.com/da-DK/not-found -> http://mysite.com/da-DK/found

Guess I'm just trying to think of the business value in being able to redirect to the site's configured default language (vs the route's context language).

I checked it and it works so as you write

/not-found -> /redirected-link
/da/not-found /da/redirected-link

@ambrauer ambrauer merged commit 82723a1 into dev Apr 28, 2023
@ambrauer ambrauer deleted the bugfix/534241-add-token-siteLang-to-redirect branch April 28, 2023 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants