htrinter / Open-Multiple-URLs

Browser extension for opening lists of URLs built on top of WebExtension with cross-browser support
GNU General Public License v3.0
252 stars 57 forks source link

URL RegExp is bad, refactor it 🐞 #21

Closed dnknn closed 3 years ago

dnknn commented 4 years ago
^https?:\/\/.+^https?:\/\/.*
user-select:none的CSS元素 要手放大 d 
df 个https://Google.com dng...哈哈

user-select:none的CSS元素 Extracted as a URL link 🐞

Preview

see 🎬gif ![Error extraction](https://user-images.githubusercontent.com/10995302/87883731-ea3d7980-ca3b-11ea-8d96-eb3b4d840c4b.gif)

Optimize and improve the regular extraction rules


/*https://google.com/*/ Error extract 👇 https://google.com/*/

URL cannot have an asterisk

see 🎬gif ![Error extraction2](https://user-images.githubusercontent.com/10995302/87883850-d47c8400-ca3c-11ea-956b-aa13707e3d99.gif)

I found that URL extract of Open-Multiple-URLs is very bad, You can experience and test the following extension, which is perfect and never goes wrong.

It can intelligently open multiple URLs in the clipboard, Improve it 👇

/https?:\/\/[\w-]+.[a-z0-9\/:%_+.,#?!@&=-]+/gi

First set option⚙ ![0713030958](https://user-images.githubusercontent.com/10995302/87256548-46e1e700-c4c6-11ea-9c27-678bdaf30a97.png) ![0713031135](https://user-images.githubusercontent.com/10995302/87256551-49dcd780-c4c6-11ea-9305-16a51b16e8da.png)
Please note that the shortcut key I set is Alt+V ,than see gif demo   ![smartpaste](https://user-images.githubusercontent.com/10995302/87256584-94f6ea80-c4c6-11ea-903d-ab2f761ba427.gif)

From the source code of Copy All Urls, it can be found that this RegExp is perfect,

and the URL will not be extracted by mistake.👇

/https?:\/\/[a-z0-9\/:%_+.,#?!@&=-]+/gi

https://github.com/vincepare/CopyAllUrl_Chrom## /https?:\/\/[a-z0-9\/:%_+.,#?!@&=-]+/gie/blob/7bad72b032f3fb36c6ad970e1448674f1ba77644/background.js#L120 0720044213

👁See RegExp testing demo 👇

https://regex101.com/r/ZSywXB/1

Screenshot ![0720044627](https://user-images.githubusercontent.com/10995302/87884946-7b185300-ca44-11ea-8d06-6bcb483ced76.png)

https://uzitech.github.io/regexper

Screenshot ![0720044931](https://user-images.githubusercontent.com/10995302/87884942-7358ae80-ca44-11ea-8874-61d5bee938c2.png)

Back to Open-Multiple-URLs , Why is there such a long and complicated URL regular?

https://github.com/htrinter/Open-Multiple-URLs/blob/a479cd88522b90f4e4bfb39df066548c16bb22d3/popup.js#L131

You can click to view to reproduce 👇

https://regex101.com/r/fxhzPz/1

0720102530

Therefore, it is recommended to change the URL regularity to

/https?:\/\/[a-z0-9\/:%_+.,#?!@&=-]+/gi

Because it is perfect, only Imperfect place 👇 0720122711


Update: You may also need to add the ~ symbol,

https://en.wikipedia.org/wiki/Rickrolling#:~:text=New%20York

because🆕 URL-API #:~:text= see more 📜👇

https://developers.google.com/web/updates/2020/02/nic80?hl=tr#more https://github.com/WICG/scroll-to-text-fragment https://chromestatus.com/feature/4733392803332096

Improve it 👇

/https?:\/\/[\w-]+\.[a-z0-9\/:%_+.,#?!@&=-]+/gi

jtagcat commented 4 years ago

Hi, could you please make a PR of your reccommended changes?

dnknn commented 4 years ago

@jtagcat Hi:)

Hi, could you please make a PR of your reccommended changes?

You refresh again please, because I just re-edited and updated this issues, It is more readable.

No, no, I don't understand PR at all, because I am not a developer, I only know how to browse 🐈github, and I don't understand code-related operations at all. I only know how to using issues and WiKi and releases(download), but I don't know how to use it anymore.

And my English is very bad, I use Google Translate , haha🤦🙈

could you please make a PR of your reccommended changes?

You help me with it, because I don't understand.

jtagcat commented 3 years ago

Hey, maybe you are interested in closing this issue as part of https://hacktoberfest.digitalocean.com ?

The accompanying videos there introduce git and/or GitHub quite nicely.