MCPcopy
hub / github.com/caronc/apprise / parse_native_url

Method parse_native_url

apprise/plugins/chime.py:313–342  ·  view source on GitHub ↗

Support native Amazon Chime webhook URLs. For example: https://hooks.chime.aws/incomingwebhooks/ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?token=AaBbCcDd%3D%3D

(url)

Source from the content-addressed store, hash-verified

311
312 @staticmethod
313 def parse_native_url(url):
314 """Support native Amazon Chime webhook URLs.
315
316 For example:
317 https://hooks.chime.aws/incomingwebhooks/
318 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?token=AaBbCcDd%3D%3D
319 """
320 result = re.match(
321 r"^https?://hooks\.chime\.aws/incomingwebhooks/"
322 r"(?P<webhook_id>[a-z0-9][a-z0-9-]*[a-z0-9])/?"
323 r"(\?.*token=(?P<token>[^&#]+).*)?$",
324 url,
325 re.I,
326 )
327 if result:
328 # Unquote the token from the native URL's query string so
329 # parse_url() receives the decoded form and can store it
330 token = result.group("token") or ""
331 return NotifyChime.parse_url(
332 "{schema}://{webhook_id}/{token}".format(
333 schema=NotifyChime.secure_protocol,
334 webhook_id=result.group("webhook_id"),
335 # Re-encode so parse_url / split_path decode it once
336 token=NotifyChime.quote(
337 NotifyChime.unquote(token), safe=""
338 ),
339 )
340 )
341
342 return None

Callers

nothing calls this directly

Calls 3

quoteMethod · 0.80
unquoteMethod · 0.80
parse_urlMethod · 0.45

Tested by

no test coverage detected