From 03c758af3eaebd6b7c18e1e595d49b0552eb5278 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Sat, 14 Jan 2023 14:53:31 -0500 Subject: browset: Support data protocol --- protocol/data.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 protocol/data.py (limited to 'protocol') diff --git a/protocol/data.py b/protocol/data.py new file mode 100644 index 0000000..a732d14 --- /dev/null +++ b/protocol/data.py @@ -0,0 +1,9 @@ +from base64 import b64decode +class DataProtocol(): + def get(url): + mime = url.split(':')[1].split(',')[0].split(';')[0] + base64 = 'base64' in url.split(',')[0].split(';') + content = ','.join(url.split(',')[1:]) + if base64: + content = b64decode(content) + return (mime or 'text/plain', [content]) -- cgit 1.4.1