Skip to content

Commit 0131cd0

Browse files
committed
commands: Add converters for IRIs
Since the 'url' and 'httpUrl' converters no longer support them...
1 parent be88530 commit 0131cd0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/commands.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ def getUrl(irc, msg, args, state):
680680
else:
681681
state.errorInvalid(_('url'), args[0])
682682

683+
def getIri(irc, msg, args, state):
684+
if utils.web.urlRe.match(args[0]):
685+
state.args.append(args.pop(0))
686+
else:
687+
state.errorInvalid(_('IRI'), args[0])
688+
683689
def getEmail(irc, msg, args, state):
684690
if utils.net.emailRe.match(args[0]):
685691
state.args.append(args.pop(0))
@@ -696,6 +702,14 @@ def getHttpUrl(irc, msg, args, state):
696702
else:
697703
state.errorInvalid(_('http url'), args[0])
698704

705+
def getHttpIri(irc, msg, args, state):
706+
if utils.web.httpUrlRe.match(args[0]):
707+
state.args.append(args.pop(0))
708+
elif utils.web.httpUrlRe.match('http://' + args[0]):
709+
state.args.append('http://' + args.pop(0))
710+
else:
711+
state.errorInvalid(_('http url'), args[0])
712+
699713
def getNow(irc, msg, args, state):
700714
state.args.append(int(time.time()))
701715

@@ -795,6 +809,7 @@ def getText(irc, msg, args, state):
795809
'haveVoice+': getHaveVoicePlus,
796810
'hostmask': getHostmask,
797811
'httpUrl': getHttpUrl,
812+
'httpIri': getHttpIri,
798813
'id': getId,
799814
'inChannel': inChannel,
800815
'index': getIndex,
@@ -828,6 +843,7 @@ def getText(irc, msg, args, state):
828843
'text': getText,
829844
'to': getTo,
830845
'url': getUrl,
846+
'iri': getIri,
831847
'user': getUser,
832848
'validChannel': validChannel,
833849
'voice': getVoice,

0 commit comments

Comments
 (0)