We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a637414 commit fe02170Copy full SHA for fe02170
1 file changed
wp-react-lib/src/util/index.js
@@ -29,7 +29,8 @@ const buildUrlRegex = () => {
29
if (!hosts.length) return null;
30
const hostsPattern = hosts.map(escapeRegex).join('|');
31
const wpRootPattern = escapeRegex(normalizeWpRoot(WP_ROOT));
32
- return new RegExp(`^(http|https)://(${hostsPattern})(?:${wpRootPattern}(?=/|$))?`, 'ig');
+ // Match scheme + allowed host + optional :port + optional WP root, with a strict boundary after the host/root.
33
+ return new RegExp(`^https?:\/\/(?:${hostsPattern})(?::\\d+)?(?:${wpRootPattern})?(?=[\/?#]|$)`, 'ig');
34
};
35
36
export const replaceLink = (url, locale) => {
0 commit comments