Skip to content

Regexp with query params fail without trailing slash after host #67

@gerard76

Description

@gerard76
require 'fakeweb'
FakeWeb.allow_net_connect = false

reg = /http:\/\/a\.com\?a=1/
uri=URI("http://a.com?a=1")
FakeWeb.register_uri(:get, reg, body: 'ok')
Net::HTTP.get(uri)

results in a FakeWeb::NetConnectNotAllowedError (Real HTTP connections are disabled. Unregistered request: GET http://a.com/?a=1)

But uri.to_s.match reg gives a match

Registering the same url without regular expression also works

FakeWeb.clean_registry
uri=URI("http://a.com?a=1")
FakeWeb.register_uri(:get, uri.to_s, body: 'ok')
Net::HTTP.get(uri)

With a regular expression you need to add the trailing slash after the hostname to get a good result

FakeWeb.clean_registry
reg = /http:\/\/a\.com\/\?a=1/
uri=URI("http://a.com?a=1")
FakeWeb.register_uri(:get, reg, body: 'ok')
Net::HTTP.get(uri)

Seems inconsistent to me

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions