miniyao
V2EX  ›  Flask

跳转 abc.com/?q=foo 用 Flask-Login 的 next 传参,需要加斜杠吗?

  •  
  •   miniyao · Feb 12, 2020 · 3581 views
    This topic created in 2291 days ago, the information mentioned may be changed or developed.

    访问 abc.com/?q=foo 路由,跳登录,然后把路径参数用 next 传进去:

    return redirect(url_for('auth.login', next='?q=foo'))
    
    return redirect(url_for('auth.login', next='/?q=foo'))
    

    虽然上面两种写法结果都一样,那种写法更符合规范呢?

    1 replies    2020-02-12 21:30:12 +08:00
    dcalsky
        1
    dcalsky  
       Feb 12, 2020
    上面那种比较好,因为可能会有 slash 处理相关的 middleware。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2842 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 01:47 · PVG 09:47 · LAX 18:47 · JFK 21:47
    ♥ Do have faith in what you're doing.