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

Page details: Fix displaying slugs with non-latin characters #51679

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export default function SidebarNavigationScreenPage() {
className="edit-site-sidebar-navigation-screen__page-link"
href={ record.link }
>
{ record.link.replace( /^(https?:\/\/)?/, '' ) }
{ decodeURI(
record.link.replace( /^(https?:\/\/)?/, '' )
) }
Copy link
Member

@Mamaduka Mamaduka Jun 20, 2023

Choose a reason for hiding this comment

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

I believe the core uses the safeDecodeURIComponent from the url package, in other places for similar fixes. We can also replace the regex here with filterURLForDisplay.

{ filterURLForDisplay( safeDecodeURIComponent( record.link ) ) }

Edit: I found my PR that fixes a similar bug in post editor - #42930.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I did not know these existed.

</ExternalLink>
}
content={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ function getPageDetails( page ) {
},
{
label: __( 'Slug' ),
value: <Truncate numberOfLines={ 1 }>{ page.slug }</Truncate>,
value: (
<Truncate numberOfLines={ 1 }>
{ decodeURI( page.slug ) }
Copy link
Member

Choose a reason for hiding this comment

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

Same here, but just safeDecodeURIComponent.

</Truncate>
),
},
];

Expand Down