Code Monkey home page Code Monkey logo

Comments (4)

mrichar1 avatar mrichar1 commented on August 21, 2024 1

Hi - thanks for reporting this issue.

The problem comes from trying to come up with a simple but effective regular expression to 'find' urls within other strings.

At present the code uses: \b\S+://\S+\b - the problem here is that the trailing slash is interpreted as a word boundary, so is removed.

I've tried other alternatives, such as: \w+:\/\/\S+ - this solves the trailing slash problem - however it instead sees all trailing punctuation as part of the url, so: click the link (http://example.com) please. results in http://example.com)

The correct solution is probably to implement a match that matches the uri rfcs - however this requires dropping a very large regex into the code - of which there are many examples, each with varying levels of 'correctness' - see for example: https://mathiasbynens.be/demo/url-regex

In this case, I'd suggest that anyone who really wants to perfectly match uris should drop one of these patterns into their patterns file and disable url matching in the config.

I'm of course very willing to accept a better regex that maintains as much simplicity as possible and removes this bug without introducing any other ones - suggestions welcome!

from clipster.

demure avatar demure commented on August 21, 2024

Would it be possible to use the deduplication feature to mitigate this?

When looking the code, I see:

# Check for growing or shrinking, but ignore duplicates
if last_item and text != last_item and (text in last_item or last_item in text):

Since the issue seems to be that first https://www.google.com enters the clipboard and then https://www.google.com/ enters the clipboard after it, could we have a check for:

if last_item+'/' == text:

or some such?

Sorry if I am miss interpreting anything here, and thanks for your time.

EDIT:

# Extracted patterns are added to the history before the selection, and the clipbaord buffer is left unchanged.

Makes it sound like the https://www.google.com is actually extracted... so I guess the above wouldn't be right then... though maybe the uri extraction could have a check for a one char change between original/extracted text?

from clipster.

stale avatar stale commented on August 21, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from clipster.

mrichar1 avatar mrichar1 commented on August 21, 2024

This may be fixed by #101 since the pattern matching regexes have been updated. Any feedback on whether this fixes things welcome!

from clipster.

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.