Find the potential JSON body from `data`. Sometimes the JSON body is prefixed with a XSSI magic string, specific to the server. Return a tuple (data prefix, actual JSON body).
(data: str)
| 25 | |
| 26 | |
| 27 | def parse_prefixed_json(data: str) -> Tuple[str, str]: |
| 28 | """Find the potential JSON body from `data`. |
| 29 | |
| 30 | Sometimes the JSON body is prefixed with a XSSI magic string, specific to the server. |
| 31 | Return a tuple (data prefix, actual JSON body). |
| 32 | |
| 33 | """ |
| 34 | matches = re.findall(PREFIX_REGEX, data) |
| 35 | data_prefix = matches[0] if matches else '' |
| 36 | body = data[len(data_prefix):] |
| 37 | return data_prefix, body |
no outgoing calls
no test coverage detected