improve magnet link regex pattern

This commit is contained in:
Alexander Bocken 2024-01-19 15:48:39 +01:00
parent 8b6a258a5e
commit b19632f496
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
3 changed files with 4 additions and 2 deletions

View File

@ -44,9 +44,11 @@ install: st
cp -f st $(DESTDIR)$(PREFIX)/bin
cp -f st-copyout $(DESTDIR)$(PREFIX)/bin
cp -f st-urlhandler $(DESTDIR)$(PREFIX)/bin
cp -f st-weechatlinks $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-urlhandler
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-weechatlinks
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1

View File

@ -1,6 +1,6 @@
#!/bin/sh
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9&=%-\.]*)"
urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
grep -aEo "$urlregex" | # grep only urls as defined above.

View File

@ -5,7 +5,7 @@
buffer="$(cat)"
#URLs:
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\!\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\!\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9&=%-\.]*)"
urls="$(echo "$buffer" | sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
grep -aEo "$urlregex" | # grep only urls as defined above.