我有以下 javascript,它接受 2 个变量(chapterid 和 txt)并将它们用作 url 中的参数。'txt' 来自用户选择。
我的问题:当用户选择中有句点时,routes.rb 文件会出现匹配 url 的问题,或者可能会忽略句点后的所有内容。
例子:
路线.rb
match "readers/chapannotations/new/:chapterid/:selection/" => "readers#newchapannotation"
javascript
url = '/readers/chapannotations/new/' + chapterid + '/' + txt + '/';
console.log(url);
window.location = url;
txt = 'O Arjuna.'
URL that opens: http://mysite.com/readers/chapannotations/new/5/O%20Arjuna./
这导致没有打开 url,因为在 routes.rb 中没有匹配的。我相信这是因为“。” 在 txt 的末尾。
txt = 'O Arjuna' http://mysite.com/readers/chapannotations/new/5/O%20Arjuna/
这个网址打开得很好,我相信是因为没有句号。