mattmilburn / strapi-plugin-menus

A plugin for Strapi CMS to customize the structure of menus and menu items.
MIT License
110 stars 28 forks source link

Allow for the use of @ in pathnames #81

Closed tefkah closed 1 year ago

tefkah commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch strapi-plugin-menus@1.2.1 for the project I'm working on.

The URL_ABSOLUTE_REGEX does not allow for the use of @ in the pathname of the URL, even though this is a valid url. This causes urls such as https://youtube.com/@youtube to be seen as invalid.

Here is the diff that solved my problem:

diff --git a/node_modules/strapi-plugin-menus/admin/src/constants.js b/node_modules/strapi-plugin-menus/admin/src/constants.js
index 81e3608..3509281 100644
--- a/node_modules/strapi-plugin-menus/admin/src/constants.js
+++ b/node_modules/strapi-plugin-menus/admin/src/constants.js
@@ -14,7 +14,7 @@ export const URL_ABSOLUTE_REGEX = new RegExp(
   '^(https?:\\/\\/)?'+
   '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+
   '((\\d{1,3}\\.){3}\\d{1,3}))'+
-  '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+
+  '(\\:\\d+)?(\\/[-a-z\\d%_.~+@]*)*'+
   '(\\?[;&a-z\\d%_.~+=-]*)?'+
   '(\\#[-a-z\\d_]*)?$',
   'i'

This issue body was partially generated by patch-package.

mattmilburn commented 1 year ago

Hi @tefkah Thank you for posting this issue 🙂 I will certainly include your PR into the next release 👍🏻