@@ -495,6 +495,25 @@ def str2value(self, value):
495495 else :
496496 return value
497497
498+ class WebUrlOption (Option ):
499+ """URL MUST start with http/https scheme and end with '/'"""
500+
501+ def str2value (self , value ):
502+ if not value :
503+ raise OptionValueError (self ,value ,"Value must not be empty." )
504+
505+ error_msg = ''
506+ if not value .startswith (('http://' , 'https://' )):
507+ error_msg = "Value must start with http:// or https://.\n "
508+
509+ if not value .endswith ('/' ):
510+ error_msg += "Value must end with /."
511+
512+ if error_msg :
513+ raise OptionValueError (self ,value ,error_msg )
514+ else :
515+ return value
516+
498517class NullableOption (Option ):
499518
500519 """Option that is set to None if its string value is one of NULL strings
@@ -714,13 +733,13 @@ def str2value(self, value):
714733 ("tracker" , (
715734 (Option , "name" , "Roundup issue tracker" ,
716735 "A descriptive name for your roundup instance." ),
717- (Option , "web" , NODEFAULT ,
736+ (WebUrlOption , "web" , NODEFAULT ,
718737 "The web address that the tracker is viewable at.\n "
719738 "This will be included in information"
720739 " sent to users of the tracker.\n "
721740 "The URL MUST include the cgi-bin part or anything else\n "
722741 "that is required to get to the home page of the tracker.\n "
723- "You MUST include a trailing '/' in the URL. " ),
742+ "URL MUST start with http/https scheme and end with '/' " ),
724743 (MailAddressOption , "email" , "issue_tracker" ,
725744 "Email address that mail to roundup should go to.\n "
726745 "If no domain is specified then mail_domain is added." ),
0 commit comments