summary refs log tree commit diff
path: root/protocol/data.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-01-14 14:53:31 -0500
committerZach DeCook <zachdecook@librem.one>2023-01-14 14:53:31 -0500
commit03c758af3eaebd6b7c18e1e595d49b0552eb5278 (patch)
tree45dffb292dbfadd1775b4d8a5e5e2a9049f177c6 /protocol/data.py
parent67bccc9e1a39ac2749806a37cb53b23322645083 (diff)
downloadbrowset-03c758af3eaebd6b7c18e1e595d49b0552eb5278.tar.gz
browset: Support data protocol
Diffstat (limited to 'protocol/data.py')
-rw-r--r--protocol/data.py9
1 files changed, 9 insertions, 0 deletions
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])