Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow #, ? and : instead of only / as the domain separator for AutoLinks #260

Merged
merged 2 commits into from
Oct 25, 2018

Conversation

MihaZupan
Copy link
Collaborator

Addresses #258

The issue with the Specs file remains, do you want me to commit it anyway?

@@ -690,7 +690,7 @@ public static bool IsValidDomain(string link, int prefixLength)

if (!c.IsAlphaNumeric())
{
if (c == '/') // End of domain name
if (c == '/' || c == '?' || c == '#' || c == ':') // End of domain name
Copy link

@AdmiringWorm AdmiringWorm Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an opinion:

this could perhaps also be written as:

if ("/?#:".Contains(c))

This would allow it to be extended to more characters in the future if needed (well, easier to extend).
Don't know if there is any performance difference though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to personal taste I guess.
Performance-wise it doesn't really matter in this case, I just try to stick to the same style as the rest of the library.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made a benchmark comparison for 5 characters in a tests (between contains and ==)

   Method |     Mean |     Error |    StdDev |   Median |
--------- |---------:|----------:|----------:|---------:|
 Contains | 641.7 ns | 12.833 ns | 31.959 ns | 629.5 ns |
   Equals | 254.1 ns |  5.030 ns |  8.403 ns | 253.0 ns |

And it seems that Equals is still faster. So yeah, let's keep equals in that case

@xoofx
Copy link
Owner

xoofx commented Oct 29, 2018

Thanks for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants