aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy
diff options
context:
space:
mode:
authorShanavas M <shanavas.m2@gmail.com>2019-01-08 17:36:46 +0530
committerShanavas M <shanavas.m2@gmail.com>2019-01-08 17:36:46 +0530
commit650a92ac9c8517c537ba85f48bcfd7eede82a248 (patch)
tree9bce8355c7ce1faa69b4c80dec439a4767562bc2 /python/tidy/servo_tidy
parent11d1184663b897e7cf0153771a8b90944ad43375 (diff)
downloadservo-650a92ac9c8517c537ba85f48bcfd7eede82a248.tar.gz
servo-650a92ac9c8517c537ba85f48bcfd7eede82a248.zip
Treat url strings are unsplittable
Fixes #22498
Diffstat (limited to 'python/tidy/servo_tidy')
-rw-r--r--python/tidy/servo_tidy/tidy.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index a8c4246ce09..35ebcb656db 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -32,6 +32,8 @@ def wpt_path(*args):
CONFIG_FILE_PATH = os.path.join(".", "servo-tidy.toml")
WPT_MANIFEST_PATH = wpt_path("include.ini")
+# regex source https://stackoverflow.com/questions/6883049/
+URL_REGEX = re.compile('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+')
# Import wptmanifest only when we do have wpt in tree, i.e. we're not
# inside a Firefox checkout.
@@ -261,8 +263,13 @@ def check_length(file_name, idx, line):
yield (idx + 1, "Line is longer than %d characters" % max_length)
+def contains_url(line):
+ return bool(URL_REGEX.search(line))
+
+
def is_unsplittable(file_name, line):
return (
+ contains_url(line) or
file_name.endswith(".rs") and
line.startswith("use ") and
"{" not in line