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

i18n: Don't rewrite blog post URLs #43610

Merged
merged 2 commits into from Jun 24, 2020
Merged

Conversation

akirk
Copy link
Member

@akirk akirk commented Jun 24, 2020

The “Learn More” link on the Jetpack > Activity Log page 404’s when using a language that has a language WordPress.com blog.

image-24

Fails: https://wordpress.com/es/blog/2018/10/30/introducing-activity/

Works: https://wordpress.com/blog/2018/10/30/introducing-activity/

props for discovering @cathymcbride

Changes proposed in this Pull Request

  • localizeUrl() should not rewrite blog post URLs since we don't have all posts translated and currently no english-slug redirects in place.

Testing instructions

  • Covered by unit tests: yarn run test-client lib/i18n-utils
  • Verify that the link above always links to the English blog post, no matter which language.

@akirk akirk added the i18n label Jun 24, 2020
@akirk akirk requested a review from yuliyan June 24, 2020 09:49
@akirk akirk self-assigned this Jun 24, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Jun 24, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~246 bytes added 📈 [gzipped])

name                   parsed_size           gzip_size
entry-main                  +166 B  (+0.0%)      +62 B  (+0.0%)
entry-login                 +166 B  (+0.0%)      +64 B  (+0.0%)
entry-gutenboarding         +166 B  (+0.0%)      +56 B  (+0.0%)
entry-domains-landing       +166 B  (+0.0%)      +64 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Member

@yuliyan yuliyan left a comment

Choose a reason for hiding this comment

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

Tested, works fine!

if (
typeof limitPathMatch === 'object' &&
limitPathMatch instanceof RegExp &&
! urlParts.pathname.match( limitPathMatch )
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: I'd use limitPathMatch.test( urlParts.pathname ) as it's a better fit in this use case (also has better performance, even though it probably won't be noticeable here).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Changed it.

if ( typeof validLocales === 'string' ) {
validLocales = config( validLocales );
}

if ( typeof limitPathMatch === 'object' && limitPathMatch instanceof RegExp ) {
if ( ! urlParts.pathname.match( limitPathMatch ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

limitPathMatch.test( urlParts.pathname ) - same as above

@akirk akirk merged commit d68e906 into master Jun 24, 2020
@akirk akirk deleted the update/localize-url-ignore-blog-posts branch June 24, 2020 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants