Method: Faker::Internet.url

Defined in:
lib/faker/default/internet.rb

.url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http') ⇒ String

Returns URL

Examples:

Faker::Internet.url                                                           #=> "http://sipes-okon.com/hung.macejkovic"
Faker::Internet.url(host: 'faker')                                            #=> "http://faker/shad"
Faker::Internet.url(host: 'faker', path: '/fake_test_path')                   #=> "http://faker/fake_test_path"
Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https')  #=> "https://faker/fake_test_path"

Parameters:

  • host (String) (defaults to: domain_name)
  • path (String) (defaults to: "/#{username}")
  • scheme (String) (defaults to: 'http')

Returns:

  • (String)

455
456
457
458
459
460
461
462
463
# File 'lib/faker/default/internet.rb', line 455

def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
  warn_for_deprecated_arguments do |keywords|
    keywords << :host if legacy_host != NOT_GIVEN
    keywords << :path if legacy_path != NOT_GIVEN
    keywords << :scheme if legacy_scheme != NOT_GIVEN
  end

  "#{scheme}://#{host}#{path}"
end