Skip to content

Commit fe02170

Browse files
ginchauspeCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a637414 commit fe02170

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

wp-react-lib/src/util/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ const buildUrlRegex = () => {
2929
if (!hosts.length) return null;
3030
const hostsPattern = hosts.map(escapeRegex).join('|');
3131
const wpRootPattern = escapeRegex(normalizeWpRoot(WP_ROOT));
32-
return new RegExp(`^(http|https)://(${hostsPattern})(?:${wpRootPattern}(?=/|$))?`, 'ig');
32+
// 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');
3334
};
3435

3536
export const replaceLink = (url, locale) => {

0 commit comments

Comments
 (0)