Replace characters with different ones
Is there a way to replace part of the URL with something else? I have some old forums links I want to visit but the formatting has changed over the years
specifically the old URL is something like this: https://www.example.com/forum/some~thread~title?postId=1 And redirect URL should replace the '~' with '%20'
I don't think there's a way to do that, since title can have any number of tildes in it I presume.
I think I can add replacement feature. Once I come up with its functionality and syntax.
I guess I can do syntax like %e[/~/%20/g] to keep the syntax as close as possible to regexes and then use String.replace(). Perhaps that is useful enough. And should it match against the whole URL then. Something like %p[1]%e[/~/%20/g] could also be nice, what I mean is that if there is a format before %e format, then that format's output will be used for %e's input, otherwise %e's input will be the whole URL. Maybe too complex.
Being able to replace just the part of selected format would be really helpful though
In your case %e[/~/%20/g] this would be good enough? But I can imagine there would be other cases where it wouldn't be enough. Having formats as input for replace format makes the code quite a lot more complex but it would be a lot more powerful.
Correct me if I'm misunderstanding, but wouldn't %e[/~/%20/g] return the entire URL with all instances of ~ being replaced?
While fine in the example, wouldn't it also effectively lock you out of using other formats?
For my actual real world use-case I also need to replace the hostname, as the forum is hosted elsewhere now, and they switched the ?postId=1 query to just a /1.
These I can already solve right now with the extension, but I feel like they would conflict with %e as is.
For clarity: https://www.example.com/forum/some~thread~title?postId=1
should become: https://www.newhost.com/forum/some%20thread%20title/1
Correct me if I'm misunderstanding, but wouldn't
%e[/~/%20/g]return the entire URL with all instances of~being replaced?
Yes, that's correct.
While fine in the example, wouldn't it also effectively lock you out of using other formats?
Pretty much, that's the downside.
I'll implement using other formats as input for %e and see how it behaves.
A new version with this feature should be soon available. With the other format used as input for %e format feature also. Hopefully it works as expected.