Apart from escaping the forward slashes after http://, you are escaping the backslash in the character class. \\w would match a backslash and a w. This part \\-\\ would match a range from \ till \ which would match a backslash.
That would match for example http://w\.:/${}=?&
As an addition, you could make a few adjustments to your regex.
(s){0,1} can be written as https?
- The character class
[\\w\\-\\.:/\$\{\}=\?&] can be written as [\w.:/${}=?&-] without the escaping of .$? and the hyphen can be moved to the beginning or at the end. \\ would match a backslash.
- If you don't need the capturing group
() you could omit that and only use an alternation |
- You could use the
/i to get a case insensitive match and the character class would become [a-z]
- Escape the dot
\. to match it literally
For example:
const regex = /^https?:\/\/[\w.:/${}=?&-]+|{\$[a-z]+\.[a-z]+}$/i;
See the Regex demo