generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 175
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
[MWPW-161098] Links conversion localization support #3120
Merged
milo-pr-merge
merged 3 commits into
adobecom:stage
from
robert-bogos:mwpw-161098-loc-support
Nov 7, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lack the context, hence the question:
No matter if this is done before or after the localization, we'd just swap out the host, no? Since localization is part of the path - we aren't touching it and this should already be done somewhere from the milo links conversion 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this does look a bit more convoluted than needed, at least at a first glance. The
localizeLink
method should handle all the complexities of handling the locale prefix. There are use-cases we need to consider, such as#_dnt
links, which should not be translated. That even has aoriginHostName
parameter, which might come in handy when trying to switch up origins.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes were necessary for use cases where different consumers share the same domain but are differentiated by path (e.g., bacom and bacom blog).
For example, without the updates in this PR, if a consumer sets the following mapping:
they would expect that, on
https://some.consumer
,business.adobe.com
would convert tobusiness.stage.adobe.com
andbusiness.adobe.com/blog
tomain--bacom-blog--adobecom.hlx.page
.This works when localization isn’t involved, but on
https://some.consumer/de
, bothbusiness.adobe.com/de/blog
andbusiness.adobe.com/de
would convert tobusiness.stage.adobe.com/de
, which is wrong.My solution is to remove the localization from the path, do the conversions and then reattach the localization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds a little confusing, would it not be already possible to add the locale part to the regex as an optional parameter? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial thought, but you'll end up losing the locale part when doing the conversion with String.replace()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robert-bogos I feel super bad for writing this now, but still curious what you think. What if we made this a config option instead? Every consumer can decide for themselves if they want their stage links converted with an option like
stageLinkTransformation: on
Then this could be opt in, you'd have way simpler code, and we'd be sending less bytes to consumers. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @mokimo @narcis-radu @overmyheadandbody if you want to chime in too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vhargrave this is already opt in, albeit the config is a bit more involved to get this running rather than just
on
. We had discussed things back and forth a lot, but settled on this and had a few iterations of it.This feature is not as trivial as one might think, has a lot of corner cases and can vary from each consumer to the next 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for explaining and sending this discussion @mokimo 🙌
I didn't realize the requirements were so broad and that config option certainly won't cover it lol.