Giter VIP home page Giter VIP logo

Comments (3)

colonelxc avatar colonelxc commented on May 21, 2024

Exposing parseUrl (or a wrapper around it) sounds reasonable. It's a bit of duplicate work for you, parsing then doing a lookup. It's also heavier than the regex solution from the xurls package.

Another solution (which was talked about in another issue) was creating exposed errors/error types that clients could match on easier. In this case, maybe it would return a ParseError which you could check via a type assertion. The problem with that for LookupURLs is that it takes a slice of URLs, but can return a single error. So you'd have to un-batch to get these benefits.

What do you think?

from safebrowsing.

aevangeline avatar aevangeline commented on May 21, 2024

I'd prefer the first solution, because we're parsing the URLs anyway to extract various components, so the rework isn't too much of an issue, whereas the latter would be a bit messy codewise, and we'd have to some rather strange error cases to handle such as what to do if one link in a message containing 3 links is not properly formatted.

from safebrowsing.

colonelxc avatar colonelxc commented on May 21, 2024

Sorry for the delayed response! I've created a pull request that exposes a "IsURL" function. It doesn't necessarily eliminate the need to do some basic string splitting/regex work to find URLs (as explained in the commit), but would prevent getting a parse error when calling LookupURLs.

from safebrowsing.

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.