Class: Phpfaker::Utils
- Inherits:
-
Object
- Object
- Phpfaker::Utils
- Defined in:
- lib/phpfaker/utils.rb
Class Method Summary collapse
- .append_php_suffix(uri) ⇒ Object
- .appended_php_suffix?(uri) ⇒ Boolean
- .drop_php_suffix(path) ⇒ Object
Class Method Details
.append_php_suffix(uri) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/phpfaker/utils.rb', line 13 def self.append_php_suffix uri uri = URI URI.escape(uri.to_s) unless uri.is_a?(URI::Generic) uri.path += case uri.path when '' '/index.php' when %r{/$} 'index.php' when %r{/[^/.]+/?$} '.php' else '' end uri end |
.appended_php_suffix?(uri) ⇒ Boolean
28 29 30 31 |
# File 'lib/phpfaker/utils.rb', line 28 def self.appended_php_suffix? uri uri = URI URI.escape(uri.to_s) unless uri.is_a?(URI::Generic) /\.(php|php3|php4|phtml)$/ =~ uri.path end |
.drop_php_suffix(path) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/phpfaker/utils.rb', line 5 def self.drop_php_suffix path path = path.to_s.dup path.sub! %r{/index\.php$}, '' path.sub! %r{(/[^/]+).(php|php3|php4|phtml)/?$}, '\1' path = '/' if path.empty? path end |