TrianguloY / UrlChecker

Android app by TrianguloY: URLCheck
Other
898 stars 52 forks source link

URL Encode/Decode Module #366

Open balporig opened 3 months ago

balporig commented 3 months ago

Describe a related problem (optional)

Could fix #358

Describe your suggested feature

Module to decode/encode URLs on demand. Probably should only be applied on the URL Parts. Useful for sharing safe URLs (encode) and getting human readable URLs (decode)

Web API reference:

Describe alternatives you've considered for your suggested feature

No response

Other details

No response

Acknowledgements

TrianguloY commented 3 months ago

The uri parts module already shows them decoded. Is that what you were asking for the decode part?

As for encoding, the pattern module can do that if you want to create a custom url, with the "encode" set to true.

balporig commented 3 months ago

The uri parts module already shows them decoded. Is that what you were asking for the decode part?

Wasn't aware of this, but no, this is not what I meant. The uri parts module displays the decoded parts but this does not apply to the original URL => copying, sharing, opening the full URL is still encoded

TrianguloY commented 3 months ago

You want to copy the url decoded? But then it won't be a valid url... Can you provide an example? Ideally some steps of what you want to achieve. I'm sorry but I'm not following.

Btw, you can click a decoded part to replace the current url with it (you lose the rest of the url, but that's usually what you want...)

yosimor commented 2 months ago

You want to copy the url decoded? But then it won't be a valid url... Can you provide an example? Ideally some steps of what you want to achieve. I'm sorry but I'm not following.

I was planning on suggesting this exact enhancement myself!

I'll give you a few examples of percent-decoding URLs containing Hebrew text. BTW, in most cases when I use this popular online URL Decoder/Encoder, the decoded URL remains a valid URL:

  1. https://he.wikipedia.org/wiki/%D7%90%D7%A0%D7%93%D7%A8%D7%95%D7%90%D7%99%D7%93_%28%D7%9E%D7%A2%D7%A8%D7%9B%D7%AA_%D7%94%D7%A4%D7%A2%D7%9C%D7%94%29 becomes https://he.wikipedia.org/wiki/אנדרואיד_(מערכת_הפעלה)
  2. https://he.wikipedia.org/wiki/%D7%A7%D7%99%D7%93%D7%95%D7%93_URL becomes https://he.wikipedia.org/wiki/קידוד_URL

Special cases where the decoded URL is not valid include those with special characters such as double-quotes in the URL, for example, this one: https://he.wikipedia.org/wiki/%D7%A7%D7%98%D7%92%D7%95%D7%A8%D7%99%D7%94%3A%D7%A0%D7%99%D7%91%D7%99%D7%9D_%D7%95%D7%91%D7%99%D7%98%D7%95%D7%99%D7%99%D7%9D_%D7%97%D7%96%22%D7%9C%D7%99%D7%99%D7%9D

In such a case, leaving just that problematic special character percent-encoded solves the problem, like this: https://he.wikipedia.org/wiki/קטגוריה:ניבים_וביטויים_חז%22ליים

I found a list of such problematic characters inside the (English) Wikipedia page on Percent-encoding:

For links within Wikipedia needing percent-encoding, see Help:URL § Fixing links with unsupported characters