Allow more freedom in page regexps
If the user starts with ^ or ends with $, do not add them. This allows using only $ or ^. If it's not a string, don't do anything to it (it has to be a regexp, or mimic one). Use search() instead of match(). They are the same, except match implies ^. This does not break any module, it only adds more possibilities.
This commit is contained in:
parent
876535ff90
commit
1621f3c3c0
1 changed files with 8 additions and 2 deletions
|
|
@ -536,8 +536,14 @@ class BaseBrowser(StandardBrowser):
|
|||
page_groups = None
|
||||
page_group_dict = None
|
||||
for key, value in self.PAGES.items():
|
||||
regexp = re.compile('^%s$' % key)
|
||||
m = regexp.match(result.geturl())
|
||||
if isinstance(key, basestring):
|
||||
if not key.startswith('^') and not key.endswith('$'):
|
||||
regexp = re.compile('^%s$' % key)
|
||||
else:
|
||||
regexp = re.compile(key)
|
||||
else:
|
||||
regexp = key
|
||||
m = regexp.search(result.geturl())
|
||||
if m:
|
||||
pageCls = value
|
||||
page_groups = m.groups()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue