Other than using regex to replace every occurrence, not just the first one as described here
(So, use str.replace(/\\/g, "/");)
You need to fix your string before passing it to JavaScript.
"some\stack\overflow" will be interpreted as "somestackoverflow". "\s" and "\o" are treated as escape sequences, not "slash letter", so the string doesn't really have any slashes. You need "some\\stack\\overflow". Why? that's why:
"s\tackoverflow" == "s ackoverflow"
"stackove\rflow" == "stackove
flow"
"\s" and "\o" just happen to not mean anything special.
str.replaceonly replaces the first occurrence" (which is part of your problem), while the hard part is replacing single unescaped\.