Append query string to url

后端 未结 6 1614
[愿得一人]
[愿得一人] 2021-02-05 08:15

I have a callback url string params[:callback] and I need to append a query string \"&result=true\" and redirect the user. The better way I found o

6条回答
  •  没有蜡笔的小新
    2021-02-05 08:47

    • if you don't need any URL validations you can do this (looks a little bit dirty):
      
      url = params[:callback]
      redirect_to url + (url.include?('?') ? '&' : '?') + 'result=true'
      
    • otherwise you have to use either some external library (like Addressable) or URI module from standard library

提交回复
热议问题