瀏覽代碼

fix parsing props with URL parameters (fixes #4453)

Falko Schindler 2 月之前
父節點
當前提交
2e6a45b31b
共有 2 個文件被更改,包括 2 次插入1 次删除
  1. 1 1
      nicegui/props.py
  2. 1 0
      tests/test_element.py

+ 1 - 1
nicegui/props.py

@@ -27,7 +27,7 @@ PROPS_PATTERN = re.compile(r'''
             '       # Match the closing quote
             '       # Match the closing quote
         )
         )
         |           # Or
         |           # Or
-        ([\w\-.,%:\/=]+)  # Capture group 4: Value without quotes
+        ([\w\-.,%:\/=?&]+)  # Capture group 4: Value without quotes
     )
     )
 )?                  # End of optional non-capturing group for value
 )?                  # End of optional non-capturing group for value
 (?:$|\s)            # Match end of string or whitespace
 (?:$|\s)            # Match end of string or whitespace

+ 1 - 0
tests/test_element.py

@@ -59,6 +59,7 @@ def test_style_parsing(value: Optional[str], expected: Dict[str, str]):
     ('loading percentage=12.5', {'loading': True, 'percentage': '12.5'}),
     ('loading percentage=12.5', {'loading': True, 'percentage': '12.5'}),
     ('size=50%', {'size': '50%'}),
     ('size=50%', {'size': '50%'}),
     ('href=http://192.168.42.100/', {'href': 'http://192.168.42.100/'}),
     ('href=http://192.168.42.100/', {'href': 'http://192.168.42.100/'}),
+    ('href=http://192.168.42.100/?foo=bar&baz=qux', {'href': 'http://192.168.42.100/?foo=bar&baz=qux'}),
     ('hint="Your \\"given\\" name"', {'hint': 'Your "given" name'}),
     ('hint="Your \\"given\\" name"', {'hint': 'Your "given" name'}),
     ('input-style="{ color: #ff0000 }"', {'input-style': '{ color: #ff0000 }'}),
     ('input-style="{ color: #ff0000 }"', {'input-style': '{ color: #ff0000 }'}),
     ('accept=.jpeg,.jpg,.png', {'accept': '.jpeg,.jpg,.png'}),
     ('accept=.jpeg,.jpg,.png', {'accept': '.jpeg,.jpg,.png'}),