22
33from  django .conf .urls  import  url  as  baseurl 
44
5- VERSION  =  (0 , 1 , 0 )
5+ VERSION  =  (0 , 1 , 1 )
66
77_macros_library  =  {
88    'id' : r'\d+' ,
@@ -27,14 +27,18 @@ def regex_group(macro, pattern):
2727    return  '(?P<%s>%s)'  %  (macro , pattern )
2828
2929
30- def  normalize_pattern (url ):
31-     return  '^%s$'  %  url .lstrip ("^ \n " ).rstrip ("$ \n " )
30+ def  normalize_pattern (url , end_dollar = True ):
31+     pattern  =  '^%s$' 
32+     if  not  end_dollar :
33+         pattern  =  '^%s' 
34+ 
35+     return  pattern  %  url .lstrip ("^ \n " ).rstrip ("$ \n " )
3236
3337
3438class  MacroUrlPattern (object ):
35-     def  __init__ (self , pattern ):
39+     def  __init__ (self , pattern ,  end_dollar = True ):
3640        self .pattern  =  pattern 
37- 
41+          self . end_dollar   =   end_dollar 
3842
3943    def  compile (self ):
4044        pattern  =  self .pattern 
@@ -48,7 +52,7 @@ def compile(self):
4852                        pattern  =  pattern .replace (match , regex_group (macro , _macros_library [_macro ]))
4953                        continue 
5054
51-         return  normalize_pattern (pattern )
55+         return  normalize_pattern (pattern ,  self . end_dollar )
5256
5357    @property  
5458    def  compiled (self ):
@@ -65,4 +69,8 @@ def __unicode__(self):
6569
6670
6771def  url (regex , view , kwargs = None , name = None , prefix = '' ):
68-     return  baseurl (MacroUrlPattern (regex ), view , kwargs = kwargs , name = name , prefix = prefix )
72+     end_dollar  =  True 
73+     if  isinstance (view , tuple ) and  len (view ) ==  3 :
74+         end_dollar  =  False 
75+ 
76+     return  baseurl (MacroUrlPattern (regex , end_dollar = end_dollar ), view , kwargs = kwargs , name = name , prefix = prefix )
0 commit comments