Giter Club home page Giter Club logo

Comments (9)

lipoja avatar lipoja commented on September 22, 2024 1

Released v1.8.0

from urlextract.

lipoja avatar lipoja commented on September 22, 2024

@GokulNC Thank you, I am glad that you are using it.

We can discuss this problem, however according to RFC3986
host = IP-literal / IPv4address / reg-name
where
reg-name = *( unreserved / pct-encoded / sub-delims )
and from that
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
and from that and RFC2234
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
I assume that domain names may contain upper-case letters.

Also RFC3986 says: The host subcomponent is case-insensitive.
Therefore I assume that somebody can write EXAMPLE.COM and he/she might be expecting to match (extract) this domain.

Do you agree?
Maybe I would go in your case with some pre-processing of text? That could help, right?

My opinion is that we can not do specific implementation to this library. I am trying to keep it as generic as possible and I do it according the books (RFCs). And I would expect that users knows the text they are processing so some special tweaks of text might be needed.

from urlextract.

GokulNC avatar GokulNC commented on September 22, 2024

Thanks for your response!

I came across this clarification regarding the above: RFC4343
Please check it out and let me know if you still think the same.

from urlextract.

lipoja avatar lipoja commented on September 22, 2024

@GokulNC Thank you for this RFC. I went through the document and I still stand by my opinion.
The RFC4343 is about DNS. If I am not wrong then DNS server should accept case-insensitive domain names. That means that in DNS request domain can appear lover-case, upper-case or combination and DNS should still return results.

I might not be correct, maybe I missed something. If it is that case could you quote from the RFC here so we can discuss it?

Thank you.

from urlextract.

GokulNC avatar GokulNC commented on September 22, 2024

Yes you are right, the domain names are treated case-insensitive, by lower-casing everything at the DNS server side.

One suggestion for this library if possible:
We can add a parameter called match_only_lowercase_domains, which can default to False as you suggested.
I believe a flag like this would give more flexibility to the users to avoid false positives like above.

Thanks!

from urlextract.

lipoja avatar lipoja commented on September 22, 2024

I will keep this suggestion in my mind. However I want to help you. What about using urlextract.ignore_list?

from urlextract import URLExtract

urlextract = URLExtract()
urlextract.ignore_list = {"s.no"}
urlextract.find_urls("random text example.com S.No. 3")

outputs:

['example.com']

from urlextract.

GokulNC avatar GokulNC commented on September 22, 2024

Thanks @lipoja ! Was not aware of ignore_list.

But, this is not possible to do, since it is not possible to construct the list of all false-positives involving such upper-case strings.

For example, consider this random example:

>>> urlextract.find_urls("I am sitting outside.In the middle of nowhere.My mind is lost in thoughts!")
['outside.In', 'nowhere.My']

from urlextract.

lipoja avatar lipoja commented on September 22, 2024

@GokulNC alright then in next release it will be available.
You can use urlextract.allow_mixed_case_hostname = False it should do the trick

from urlextract.

GokulNC avatar GokulNC commented on September 22, 2024

That's awesome! Thanks alot @lipoja :)

from urlextract.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.