code: function formatReferer(ctx, pathname, rootPath) {
    const query = ctx.query;
    let referer = query.redirect || ctx.get('referer') || rootPath;
    if (referer[0] !== '/') {
      // ignore protocol://xxx/abc
      referer = rootPath;
    } else if (referer.indexOf(pathname) === 0) {
      // referer start with loginPath or logoutPath, just redirect to rootPath
      referer = rootPath;
    }
    return referer;
  }
docs: formate referer
  @param {Context} ctx
  @param {String} pathname - login path or logout path
  @param {String} rootPath
  @return {String}
  
  @api private