aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/utils.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-02-08 23:10:29 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-02-08 23:10:29 +1300
commitb1b94b49e4e1009125bc1375f71c6c755d1978d5 (patch)
tree750be1224dcf8d10d1b63bc9665b1357184566ac /libmproxy/utils.py
parent56d2f9fbdbbd5992a8a1af9383936a49ef0fa8e3 (diff)
parent5df0b9e9610b803241f8c4870ddfe3afb450a048 (diff)
downloadmitmproxy-b1b94b49e4e1009125bc1375f71c6c755d1978d5.tar.gz
mitmproxy-b1b94b49e4e1009125bc1375f71c6c755d1978d5.tar.bz2
mitmproxy-b1b94b49e4e1009125bc1375f71c6c755d1978d5.zip
Merge branch 'kveditor'
Conflicts: libmproxy/console.py
Diffstat (limited to 'libmproxy/utils.py')
-rw-r--r--libmproxy/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index 4e53e6ce..4339ec6d 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -411,6 +411,18 @@ def parse_url(url):
return scheme, host, port, path
+def clean_hanging_newline(t):
+ """
+ Many editors will silently add a newline to the final line of a
+ document (I'm looking at you, Vim). This function fixes this common
+ problem at the risk of removing a hanging newline in the rare cases
+ where the user actually intends it.
+ """
+ if t[-1] == "\n":
+ return t[:-1]
+ return t
+
+
def parse_size(s):
"""
Parses a size specification. Valid specifications are: