<commit_before># encoding: utf-8
#--
#   Copyright (C) 2012 Gitorious AS
#   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
#   Copyright (C) 2007, 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2009 <NAME> <<EMAIL>>
#   Copyright (C) 2009 <NAME> <<EMAIL>>
#   Copyright (C) 2010 <NAME> <<EMAIL>>
#
#   Copyright (C) 2011 Gitorious AS
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++

# These helpers are used both in views and some controllers
#
module RoutingHelper
  # turns ["foo", "bar"] route globbing parameters into "foo/bar"
  # Note that while the path components will be uri unescaped, any
  # '+' will be preserved
  def desplat_path(*paths)
    # we temporarily swap the + out with a magic byte, so
    # filenames/branches with +'s won't get unescaped to a space
    paths.flatten.compact.map do |p|
      CGI.unescape(p.gsub("+", "\001")).gsub("\001", '+')
    end.join("/")
  end

  # turns "foo/bar" into ["foo", "bar"] for route globbing<commit_msg>Operate on ascii-8bit string when desplatting a path<commit_after># encoding: utf-8
#--
#   Copyright (C) 2012 Gitorious AS
#   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
#   Copyright (C) 2007, 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2008 <NAME> <<EMAIL>>
#   Copyright (C) 2009 <NAME> <<EMAIL>>
#   Copyright (C) 2009 <NAME> <<EMAIL>>
#   Copyright (C) 2010 <NAME> <<EMAIL>>
#
#   Copyright (C) 2011 Gitorious AS
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++

# These helpers are used both in views and some controllers
#
module RoutingHelper
  # turns ["foo", "bar"] route globbing parameters into "foo/bar"
  # Note that while the path components will be uri unescaped, any
  # '+' will be preserved
  def desplat_path(*paths)
    # we temporarily swap the + out with a magic byte, so
    # filenames/branches with +'s won't get unescaped to a space
    paths.flatten.compact.map do |p|
      p.force_encoding('ascii-8bit') if p.respond_to?(:force_encoding)
      CGI.unescape(p.gsub("+", "\001")).gsub("\001", '+')
    end.join("/")
  end

  # turns "foo/bar" into ["foo", "bar"] for route globbing
{'fraction_non_alphanumeric': 0.11596638655462185, 'fraction_numerical': 0.02969187675070028, 'mean_word_length': 3.655801825293351, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4095357', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1088, 'n_words': 467}