[CSHARP-4817] class ConnectionString can't Parse '-' in their hostname. Created: 23/Oct/23  Updated: 31/Oct/23  Resolved: 31/Oct/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Rickard Nilsson Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CSHARP-4816 class ConnectionString. Can't parse '... Closed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

if you have a host name like "hello-world.se" the parse function will fail and throw an execption.
It is missing a '-' in the regexp.



 Comments   
Comment by Robert Stam [ 31/Oct/23 ]

Thanks for letting us know that it's working for you.

Comment by Rickard Nilsson [ 30/Oct/23 ]

I am soo sorry, must've been a glitch in the matrix or something, I really had that problem, Even chat gpt told me that the hyphen would be a problem. (worked without and not with) But now when I try I get no problem at all, and chat gpt gives a totaly different answer given the same question.

 

Oh well, sorry for this non issue..

 

/Rickard

Comment by Rickard Nilsson [ 30/Oct/23 ]

I'll get back to it tomorrow. But it is strange that you don't get that error. I will see if I had an old version or something. Because I did download the latest NuGet package. 

Comment by Robert Stam [ 30/Oct/23 ]

If you still think this is an issue can you please provide me with a copy of your connection string (be sure to remove any confidential information).

Thanks!

Comment by Robert Stam [ 30/Oct/23 ]

Actually I am not able to reproduce this (I only thought I could because I had a typo in my first tests).

The following tests pass:

public class CSharp4817Tests
{
    [Fact]
    public void ConnectionString_with_dash_in_host_name_should_work()
    {
        var subject = new ConnectionString("mongodb://hello-world.se");
 
        var (host, port) = subject.Hosts.Single().GetHostAndPort();
        host.Should().Be("hello-world.se");
        port.Should().Be(27017);
    }
 
    [Fact]
    public void MongoUrl_with_dash_in_host_name_should_work()
    {
        var subject = new MongoUrl("mongodb://hello-world.se");
 
        var server = subject.Server;
        server.Host.Should().Be("hello-world.se");
        server.Port.Should().Be(27017);
    }
}

 

Comment by Robert Stam [ 30/Oct/23 ]

Thank you for reporting this. I am able to reproduce it and am working on a fix.

Comment by PM Bot [ 23/Oct/23 ]

Hi ricknils@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.