Forum Discussion
pramita
6 years agoHelper II
How to decode URL component using M Language?
I have a column with links in it, I need to decode it. The links are encoded, in %s as shown below For example: https%3A%2F%2Fwww.rnd.de%2Fpanorama%2Fzwei-flugzeuge-stossen-im-munsterland-zus...
lbendlin
6 years agoSuper User
Don't forget that there is always the brute force method. After all there are not that many encoded characters in the majority of URLs.
You can extend the below to also cover ? and & and space.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("DYjLCsIwEAD/pdDj5lBBz7VFvQjax0FKD5GsbSCbhGZDIF9vYA4zsyzVzuxDfWrr5lZIKYnDKqGwhJfWHZJk0ZxQw8/ELWPcEAK7ENCCJqBoA+NhpFWQY5BE5X9RKwSvjeNS7Bg+/eP+HF7tNHTztTuPXd83l2l8D7PYmUy1rn8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Replaced Value" = Table.ReplaceValue(Source,"%3A",":",Replacer.ReplaceText,{"Column1"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","%2F","/",Replacer.ReplaceText,{"Column1"})
in
#"Replaced Value1"