/*
AuthModule getRedirectTo

@param {Object|String} options
#param {String} page
@return {String}
@api public
341919
function getRedirectTo(options, page) {
    if( typeof options === 'string' ) {
        options = {redirectTo: options};
    }
    options = options || {};
    page = page || 'root';
    return options.redirectTo || defaults[page];
}
1009733
function authorizationRequest (req, options) {
  var provider = this.provider
  var endpoints = this.endpoints
  var config = this.client
  var url = URL.parse(endpoints.authorize.url)
  var responseType = 'code'
  var clientId = config.client_id
  var redirectUri = provider.redirect_uri
  var state = options.state

  // required authorization parameters
  url.query = {
    response_type: responseType,
    client_id: clientId,
    redirect_uri: redirectUri
  }

  // merge default and configured scopes
  if (provider.scope || config.scope) {
    var s1 = provider.scope || []
    var s2 = config.scope || []
    var sp = provider.separator || ' '

    url.query.scope = s1.concat(s2).join(sp)
  }

  if (state) {
    url.query.state = state
  }

  // Redirect to the provider. This method is
  // added at runtime by passport and not explicitly
  // defined here.
  this.redirect(URL.format(url))
}
578123
function(options) {
    options = options || {};

    // Allow dom_id to be overridden
    if (options.dom_id) {
      this.dom_id = options.dom_id;
      delete options.dom_id;
    }

    if (!options.supportedSubmitMethods){
      options.supportedSubmitMethods = [
        'get',
        'put',
        'post',
        'delete',
        'head',
        'options',
        'patch'
      ];
    }

    if (typeof options.oauth2RedirectUrl === 'string') {
      window.oAuthRedirectUrl = options.redirectUrl;
    }

    // Create an empty div which contains the dom_id
    if (! $('#' + this.dom_id).length){
      $('body').append('<div id="' + this.dom_id + '"></div>') ;
    }

    this.options = options;

    // set marked options
    marked.setOptions({gfm: true});

    // Set the callbacks
    var that = this;
    this.options.success = function() { return that.render(); };
    this.options.progress = function(d) { return that.showMessage(d); };
    this.options.failure = function(d) { return that.onLoadFailure(d); };

    // Create view to handle the header inputs
    this.headerView = new SwaggerUi.Views.HeaderView({el: $('#header')});

    // Event handler for when the baseUrl/apiKey is entered by user
    this.headerView.on('update-swagger-ui', function(data) {
      return that.updateSwaggerUi(data);
    });
  }
775057
function get (url, cb) {
  var urls = [], end
  _get(url, cb)
  function _get (url) {
    urls.push(url)
    if(end) return
    if(urls.length > 5)
      cb(end = new Error('too many redirects\n'+JSON.stringify(urls)))

    console.error('GET', url)
    ;(/^https/.test(url) ? https : http).get(url, function next (res) {

      if(res.statusCode >= 300 && res.statusCode < 400)
        _get(res.headers.location)
      else {
        end = true,
        cb(null, res)
      }
    })
    .on('error', function (err) {
      if(!end)
        cb(end = err)
    })
  }
}
252168
public function redirect($from, $to, array $params = [])
    {
        $this->add('REDIRECT', $from, function () use ($to, $params) {
            $code = !empty($params['code'])
                ? $params['code']
                : 307;

            if (!empty($params['route'])) {
                $args = !empty($params['args'])
                    ? $params['args']
                    : [];

                $to   = $this->getRoute($params['route'], is_array($args) ? $args : []);
            }

            header('location: ' . $to, true, $code);
            exit;
        }, $params);

        return $this;
    }
416065
function (src, options) {

		    var pack = (config.pageConfig &&
		            config.pageConfig.project &&
		            config.pageConfig.project.source )?
		                config.pageConfig.project :
		                false;

		    if (src && pack){
		        return options.fn(this);
		    }else{
		        return options.inverse(this);
		    }
		}
12493
function renderPage(page) {
  if (!page) return '';

  var args = [];

  if (page.category) args.push(page.category);
  if (page.name) args.push(page.name);
  if (page.properties) args.push(page.properties);

  // eslint-disable-next-line no-restricted-globals
  var res = 'analytics.page(' + map(JSON.stringify, args).join(', ') + ');';

  return res;
}
703673
function _get_admin_page_url( $page = '', $params = array(), $network = null ) {
            if ( is_null( $network ) ) {
                $network = (
                    $this->_is_network_active &&
                    ( fs_is_network_admin() || ! $this->is_delegated_connection() )
                );
            }

            if ( 0 < count( $params ) ) {
                foreach ( $params as $k => $v ) {
                    $params[ $k ] = urlencode( $v );
                }
            }

            $page_param = $this->_menu->get_slug( $page );

            if ( empty( $page ) &&
                 $this->is_theme() &&
                 // Show the opt-in as an overlay for free wp.org themes or themes without any settings page.
                 ( $this->is_free_wp_org_theme() || ! $this->has_settings_menu() )
            ) {
                $params[ $this->get_unique_affix() . '_show_optin' ] = 'true';

                return add_query_arg(
                    $params,
                    $this->admin_url( 'themes.php', 'admin', $network )
                );
            }

            if ( ! $this->has_settings_menu() ) {
                if ( ! empty( $page ) ) {
                    // Module doesn't have a setting page, but since the request is for
                    // a specific Freemius page, use the admin.php path.
                    return add_query_arg( array_merge( $params, array(
                        'page' => $page_param,
                    ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
                } else {
                    if ( $this->is_activation_mode() ) {
                        /**
                         * @author Vova Feldman
                         * @since  1.2.1.6
                         *
                         * If plugin doesn't have a settings page, create one for the opt-in screen.
                         */
                        return add_query_arg( array_merge( $params, array(
                            'page' => $this->_slug,
                        ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
                    } else {
                        // Plugin without a settings page.
                        return add_query_arg(
                            $params,
                            $this->admin_url( 'plugins.php', 'admin', $network )
                        );
                    }
                }
            }

            // Module has a submenu settings page.
            if ( ! $this->_menu->is_top_level() ) {
                $parent_slug = $this->_menu->get_parent_slug();
                $menu_file   = ( false !== strpos( $parent_slug, '.php' ) ) ?
                    $parent_slug :
                    'admin.php';

                return add_query_arg( array_merge( $params, array(
                    'page' => $page_param,
                ) ), $this->admin_url( $menu_file, 'admin', $network ) );
            }

            // Module has a top level CPT settings page.
            if ( $this->_menu->is_cpt() ) {
                if ( empty( $page ) && $this->is_activation_mode() ) {
                    return add_query_arg( array_merge( $params, array(
                        'page' => $page_param
                    ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
                } else {
                    if ( ! empty( $page ) ) {
                        $params['page'] = $page_param;
                    }

                    return add_query_arg(
                        $params,
                        $this->admin_url( $this->_menu->get_raw_slug(), 'admin', $network )
                    );
                }
            }

            // Module has a custom top level settings page.
            return add_query_arg( array_merge( $params, array(
                'page' => $page_param,
            ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
        }
1342166
public static function Redirect($page, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null)
    {
        if (self::$app instanceof WebApplication) {
            self::$app->getResponse()->Redirect($page, $arg1, $arg2, $arg3, $arg4, $arg5);
        }
    }
118930
function(url)
    {
      //Parse the redirected url
      return provider.authorization_done(opt, url, window, function()
      {
        //Destroy the window
        window.destroy();

        //Get the arguments
        var args = [].slice.call(arguments);

        //Do the callback with the provided arguments
        return cb.apply(null, args);
      });
    }
358810
public static String getRedirectDestination(String pageText) {
		String redirectString = null;
		try {
			String regex = "\\[\\[\\s*(.+?)\\s*]]";
			Pattern pattern = Pattern.compile(regex);
			Matcher matcher = pattern.matcher(pageText);

			// group 0 is the whole match
			if (matcher.find()) {
				redirectString = matcher.group(1);
			}
			if (redirectString == null) {
				return null;
			}

			// remove anchor (case: "#Redirect [[Article #Anchor]])
			String[] anchorSplitValues = redirectString.split("#");
			redirectString = anchorSplitValues[0];
			// remove whitespace (case: "Article " - when splitting the example
			// above)
			redirectString = redirectString.trim();

			// remove direct|redirect alternatives
			String[] directSplitValues = redirectString.split("\\|");
			redirectString = directSplitValues[0];
			// remove whitespace (case: "Article " - when splitting the example
			// above)
			redirectString = redirectString.trim();

			// remove whitespace (case: "Article " - when splitting the example
			// above)
			redirectString = redirectString.trim();

			// remove namespace string (case:
			// "#REDIRECT [[Portal:Recht/Liste der Rechtsthemen]]")
			// but there are names with colons in it => consider only cases
			// where
			// there are no spaces around the colon
			String regexNamespace = ":([^\\s].+)";
			Pattern patternNamespace = Pattern.compile(regexNamespace);
			Matcher matcherNamespace = patternNamespace.matcher(redirectString);

			// group 0 is the whole match
			if (matcherNamespace.find()) {
				redirectString = matcherNamespace.group(1);
			}

			// replace spaces with underscores (spaces are represented as
			// underscores in page titles)
			// e.g. "Englische Grammatik"
			redirectString = redirectString.replace(" ", "_");

			// page titles always start with a capital letter
			if (redirectString.length() > 0) {
				redirectString = redirectString.substring(0, 1).toUpperCase()
						+ redirectString.substring(1, redirectString.length());
			}
		} catch (Exception e) {
			redirectString = null;
			logger.debug("Error in Redirects ignored");
		}

		return redirectString;
	}
1097568
def page(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None,
             allow_redirects=False):
        
        return self.request(
            method,
            uri,
            params=params,
            data=data,
            headers=headers,
            auth=auth,
            timeout=timeout,
            allow_redirects=allow_redirects,
        )
185696
function handleRedirect(redirect, state, params, options) {
      /**
       * @ngdoc event
       * @name ui.router.state.$state#$stateNotFound
       * @eventOf ui.router.state.$state
       * @eventType broadcast on root scope
       * @description
       * Fired when a requested state **cannot be found** using the provided state name during transition.
       * The event is broadcast allowing any handlers a single chance to deal with the error (usually by
       * lazy-loading the unfound state). A special `unfoundState` object is passed to the listener handler,
       * you can see its three properties in the example. You can use `event.preventDefault()` to abort the
       * transition and the promise returned from `go` will be rejected with a `'transition aborted'` value.
       *
       * @param {Object} event Event object.
       * @param {Object} unfoundState Unfound State information. Contains: `to, toParams, options` properties.
       * @param {State} fromState Current state object.
       * @param {Object} fromParams Current state params.
       *
       * @example
       *
       * <pre>
       * // somewhere, assume lazy.state has not been defined
       * $state.go("lazy.state", {a:1, b:2}, {inherit:false});
       *
       * // somewhere else
       * $scope.$on('$stateNotFound',
       * function(event, unfoundState, fromState, fromParams){
       *     console.log(unfoundState.to); // "lazy.state"
       *     console.log(unfoundState.toParams); // {a:1, b:2}
       *     console.log(unfoundState.options); // {inherit:false} + default options
       * })
       * </pre>
       */
      var evt = $rootScope.$broadcast('$stateNotFound', redirect, state, params);

      if (evt.defaultPrevented) {
        $urlRouter.update();
        return TransitionAborted;
      }

      if (!evt.retry) {
        return null;
      }

      // Allow the handler to return a promise to defer state lookup retry
      if (options.$retry) {
        $urlRouter.update();
        return TransitionFailed;
      }
      var retryTransition = $state.transition = $q.when(evt.retry);

      retryTransition.then(function() {
        if (retryTransition !== $state.transition) return TransitionSuperseded;
        redirect.options.$retry = true;
        return $state.transitionTo(redirect.to, redirect.toParams, redirect.options);
      }, function() {
        return TransitionAborted;
      });
      $urlRouter.update();

      return retryTransition;
    }
840522
function oauth2callback(options) {
  return function(req, res, next) {
    const { service_name, } = options;
    const entitytype = req.session.passport.user.entitytype || 'user';
    const redirectURL = (entitytype === 'account') ? passportExtSettings.redirect.account.logged_in_homepage : passportExtSettings.redirect.user.logged_in_homepage;
    const loginEntityURL = (entitytype === 'account') ? passportLocals.paths.account_auth_login : passportLocals.paths.user_auth_login;
    const loginUrl = (req.session.return_url) ?
      req.session.return_url :
      redirectURL;
    const loginFailureUrl = (req.session.return_url) ?
      req.session.return_url :
      loginEntityURL + '?return_url=' + req.session.return_url;
    // console.log({ loginUrl, loginFailureUrl, redirectURL, loginEntityURL, });
    // console.log({ entitytype, redirectURL, loginEntityURL, loginUrl, loginFailureUrl }, 'req.session', req.session, 'req.user', req.user,'req.headers', req.headers,{service_name});
    passport.authenticate(`oauth2client-${service_name}`, {
      successRedirect: loginUrl,
      failureRedirect: loginFailureUrl,
      failureFlash: `Invalid ${service_name} authentication credentials username or password.`,
    })(req, res, next);
  };
}
42814
function login(options) {
  const defaultHost = options.host;
  return async function loginHandler(ctx) {
    const loginCallbackPath = options.loginCallbackPath;
    const loginPath = options.loginPath;
    // ctx.session should be exists
    if (ctx.session) {
      ctx.session.userauthLoginReferer = formatReferer(ctx, loginPath, options.rootPath);
      debug('set loginReferer into session: %s', ctx.session.userauthLoginReferer);
    }

    const host = defaultHost || ctx.host;
    const protocol = options.protocol || ctx.protocol;
    const currentURL = protocol + '://' + host + loginCallbackPath;
    const loginURL = options.loginURLFormatter(currentURL, options.rootPath, ctx);
    debug('login redrect to loginURL: %s', loginURL);
    redirect(ctx, loginURL);
  };
}
1068548
def get_post_authorization_redirect_url(request, canvas=True):
    

    path = request.get_full_path()

    if canvas:

        if FACEBOOK_APPLICATION_CANVAS_URL:
            path = path.replace(urlparse(FACEBOOK_APPLICATION_CANVAS_URL).path, '')

        redirect_uri = 'https://%(domain)s/%(namespace)s%(path)s' % {
            'domain': FACEBOOK_APPLICATION_DOMAIN,
            'namespace': FACEBOOK_APPLICATION_NAMESPACE,
            'path': path
        }
    else:
        if FANDJANGO_SITE_URL:
            site_url = FANDJANGO_SITE_URL
            path = path.replace(urlparse(site_url).path, '')
        else:
            protocol = "https" if request.is_secure() else "http"
            site_url = "%s://%s" % (protocol, request.get_host())
        redirect_uri = site_url + path

    return redirect_uri
1185285
function (pageNum) {
            var textPath = util.template(config.template.html, { page: pageNum });
            return config.url + textPath + config.queryString;
        }