使用base64的路由器生成了param

时间:2014-02-25 15:59:58

标签: node.js geddy

我试图在将参数转换为基数64后发送参数geddy.js route的定义:

router.get(routing_prefix+'/gogetthecart/:data').to('Main.gogetthecart');

在客户端,javascript,我生成一个base64 json数据var jsonb64 = btoa(JSON.stringify(params));之后,我调用了会像这样的网址

http://www.mydomain.com//gogetthecart/GVudGl...aWNo=

错误:404 Not Found ..但如果我从有效数据的末尾手动删除 =

1 个答案:

答案 0 :(得分:0)

社区解决git repos问题https://github.com/geddy/geddy/issues/556正如Kieran所说

  

我考虑将对base64编码变量的支持添加到Barista   直接,但是在URI中保留了b64规范中的一些字符   规范。我认为这是默认行为,我感到很自在。

     

然而!您可以简单地覆盖行为以支持此用途   情况下:

router
.get( routing_prefix+'/gogetthecart/:data')
.to('Main.gogetthecart')
.where({
  data: /[\w\-\/+]+={0,2}/ // base64-safe regex condition
})
     

这应该可以做到!

     

我在这里添加了一个测试:   https://github.com/kieran/barista/blob/master/tests/barista.test.js#L812