<commit_before>/**
 * 303 (See Other) Handler for Rstudio-api (passes parameters)
 *
 * Usage:
 * return res.rstudio_redirect(uri)
 *
 * e.g.:
 * ```
 * return res.rstudio_redirect(uri)
 * ```
 *
 * NOTE:
 * This response is needed if the viewer_pane parameter, the Rstudio_port and/or the session_shared_secret for Rstudio or important
 * This is for example the case when refering to topics, as topic/show.ejs has viewer_pane-specifid code.
 */

 module.exports = function rstudio_redirect(code,uri) {

// Get access to `req`, `res`, & `sails`
  var req = this.req;
  var res = this.res;
  var sails = req._sails;

  var urlParams="";

  urlParams='?viewer_pane='+encodeURIComponent(req.param("viewer_pane"))+
    '&Rstudio_port='+encodeURIComponent(req.param('Rstudio_port'))+
    "&RS_SHARED_SECRET="+encodeURIComponent(req.param('RS_SHARED_SECRET'))+
    "&rstudio_layout="+encodeURIComponent(req.param('rstudio_layout'));

  sails.log.silly('res.restudio_redirect() :: Sending '+code+ ' (redirect) response');
  res.redirect(code,uri+urlParams);
};<commit_msg>fix rstudio_redirect<commit_after>/**
 * 303 (See Other) Handler for Rstudio-api (passes parameters)
 *
 * Usage:
 * return res.rstudio_redirect(uri)
 *
 * e.g.:
 * ```
 * return res.rstudio_redirect(uri)
 * ```
 *
 * NOTE:
 * This response is needed if the viewer_pane parameter, the Rstudio_port and/or the session_shared_secret for Rstudio or important
 * This is for example the case when refering to topics, as topic/show.ejs has viewer_pane-specifid code.
 */

 module.exports = function rstudio_redirect(code,uri) {

// Get access to `req`, `res`, & `sails`
  var req = this.req;
  var res = this.res;
  var sails = req._sails;

  var urlParams= ['viewer_pane', 'Rstudio_port', 'RS_SHARED_SECRET', 'rstudio_layout'].map(function(p) {
    return req.param(p) ? p + '=' + encodeURIComponent(req.param(p)) : '';
  }).filter(function(p) {
    return p !== '';
  }).join('&');

  if(urlParams) urlParams = '?' + urlParams;

  sails.log.silly('res.restudio_redirect() :: Sending '+code+ ' (redirect) response');
  res.redirect(code,uri+urlParams);
};
{'fraction_non_alphanumeric': 0.15493623051487954, 'fraction_numerical': 0.002834199338686821, 'mean_word_length': 4.618037135278515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '105712', 'n_tokens_mistral': 771, 'n_tokens_neox': 762, 'n_words': 168}