Skip to content
Merged
Changes from 5 commits
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 @@ -13,7 +13,7 @@ import {
file,
} from '@wordpress/icons';
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
import { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';

const ICONS_MAP = {
post: postList,
Expand Down Expand Up @@ -52,9 +52,15 @@ export const LinkControlSearchItem = ( {
isURL = false,
shouldShowType = false,
} ) => {
// Remove the site URL from any suggestion that is not a manually entered URL.
// This is to reduce visual noise in the search results.
const suggestionURL = isURL
? suggestion?.url
: '/' + getPath( suggestion?.url ) + '/';

const info = isURL
? __( 'Press ENTER to add this link' )
: filterURLForDisplay( safeDecodeURI( suggestion?.url ), 24 );
: filterURLForDisplay( safeDecodeURI( suggestionURL ), 24 );

return (
<MenuItem
Expand Down