aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/pathname/clean_within.rb
blob: 89690252b15d31df95b0424901f64116cd2ae4db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
require 'pathname'

class Pathname
  # Clean the paths contained in the provided string.
  def self.clean_within(string)
    string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path|
      new(path).cleanpath
    end
  end
end