English 中文(简体)
Railways 3.1: UrlEncode issues with period (a).
原标题:Rails 3.1: UrlEncode issues with periods (.)

我有一个网站,一个用户搜索艺术家、歌曲或书目和点击,展示搜索结果。 然后,个人搜索术语被定为可点击,意思是每一次使用自己的途径(或路线)产生联系。

我所处理的问题是,一些艺术家、歌曲或歌唱名(例如(时间))的随机杂交。 是否有哪条路要ur?

Here is my current code:

<% artists[0..5].each do |art| %>
                        <li><span><strong><%= link_to "#{art}", artist_path(CGI::escape(art)) %></strong></span></li>
                <% end %>
问题回答

Assume You have an page name known "slash@^[]/=hi?qqq=123"

encoded = URI.escape str_to_be_encoded

encoded = URI.escape(str_to_be_encoded, Regexp.new("[^#{URI::PATTERN::UNRESERVED.gsub( . ,  )}]"))

第一种做法是编码。

"slash@%5E[]/=hi?qqq=123"

第二种是编码。

"slash%40%5E%5B%5D%2F%3Dhi%3Fqqq%3D123"

发生的情况是,大多数冷藏方法不会逃避其认为是价值ur的一部分的特性,因此,像平等一样的象征和问题标志不会逃脱。

第二种方法说明越狱功能也越狱。 因此,你获得了更好的编码。

然后,你可以像你一样向你们致敬。

"http://localhost:3000/albums/1-#{encoded}"

希望这一帮助。





相关问题
Help with C# HttpWebRequest URI losing its encoding

Having a problem with HttpWebRequest decoding my encoded URL. var requestUrl = "https://www.google.com/webmasters/tools/feeds/http%3A%2F%2Fwww%2example%2Ecom%2F/crawlissues/"; var request = (...

NSDictionary: URL-Encoding

Can anyone please review the following method and tell me if it is necessary to release the enumerator for the dictionary keys after using it? I m new to objective c and not always sure, when to ...

How to handle & in URL sent as HTML from iPhone Mail.app

Apologies if this has been answered already. There are similar topics but none that I could find pertaining to Cocoa & NSStrings... I m constructing a clickable URL to embed in an HTML email to ...

How to mimic ASP Server.URLEncode in ASP.NET?

In ASP: Server.URLEncode("+&(). -*<>/|") returns %2B%26%28%29%2E+%2D%2A%3C%3E%2F%5C%7C In ASP.NET Uri.EscapeDataString("+&(). -*<>/|") // returns %2B%26().%20-*%3C%3E%2F%5C%...

How do I parse an encoded URI in Ruby?

I m trying to parse a URI that has brackets - [ and ] - in it. I have tried to parse this directly with URI.parse but the brackets cause this to fail. I therefore tried to encode the URI with CGI::...

Percent Encoded UTF-8 to Ascii(8-bit) conversion

Im reading in urls and they often have percent encoded characters. Example: %C3%A9 is actually é According to http://www.microsystools.com/products/sitemap-generator/faq/character-percentage-url-...

热门标签