As far as I remember reading, in 8.5 getUrl would return a string but this was actually incorrect and it should have returned an object of a class. They have since fixed this in 8.5.1+.
If you wrap your str variable in @Text or use toString (if you don;t want to use @Formula) that should fix it for you.