drba1172 2014-06-11 14:02
浏览 282
已采纳

%2F而不是网址中的斜杠?

I have a problem with jquery syntax in an url link:

this is the link i am getting (englisch):

...myaccount/?lang=en%2Fprint-order%2F2067%2F&print-order-type=receipt

this is the german link:

...myaccount/print-order/2067/?print-order-type=receipt

the problem now is, that the link looks ok in my browser

myaccount/print-order/2067/?print-order-type=receipt

but actually there's always a "%2F" instead of a "/" inside the link when I copy it which leads to the problem of getting an 404.

When I manually replace "%2F" the link works.

Where is the problem? Any idea to fix this?

The code below comes from woocommerce/templates/myaccount/my-orders.php

if ($actions) { foreach ( $actions as $key => $action ) { echo '<a
 href="' . esc_url( $action['url'] ) . '" class="button ' .
 sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) .
 '</a>'; }

It generates the "Print" button on the "my orders" page. I am using mqtranslate german/englisch. In the german version everything works- the links are correct, ony when i switch the language there are "%2f" instead of "/". But also only after the first part (until myaccount/) - because some "/" are correctly encoded.

Also in the english version it's a "&" before "print-order-type=receipt" instead of a "?".

  • 写回答

2条回答 默认 最新

  • dtc4547 2014-06-11 14:23
    关注

    Use decodeURIComponent on the copied value:

    decodeURIComponent('myaccount/?lang=en%2Fprint-order%2F2067%2F?print-order-type=receipt')
    

    http://jsfiddle.net/7hySU/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站