Regex to check for valid URL in Firebase Security Rule -


i'm trying implement firebase security rule check if valid url using regex. here sample of url :

https://firebasestorage.googleapis.com/andtherestisjustthepartafteriuploadedintofirebasestorage 

i used regex check:

"imageurl": {       ".validate": "newdata.val().matches(/((([a-za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[a-za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[a-za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/)"  } 

however, i'm getting error @ line 26: invalid escape: '\+'.

any ideas?

its not necessary escape + in regex class, instead use this:

[-+=&;%@.\w_] 

i see syntax errors in pattern, character should escaped athors should not, pattern should :

/((([a-za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=+\\$,\\w]+@)?‌​[a-za-z0-9.-]+|(?:ww‌​w.|[-;:&=+\\$,\\w]+@‌​)[a-za-z0-9.-]+)((?:‌​\\/[%+~\\/.\\w-_]*)?‌​\\??(?:[-+=&;%@.\\w_‌​]*)#?(?:[\\w]*))?)/ 

but i'm not sure of logic of pattern, suggest read more information firebase security rules regular expressions


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -