generated from thclark/django-rabid-armadillo
    
        
        - 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
Open
Labels
bugUnintended behaviour in any area of the appUnintended behaviour in any area of the app
Description
Feature request
Current state
We've arrived at urls like: https://shae422ab4---windquest-worker-main-pxjn2zhfgq-ew.a.run.app//django-gcp/events/q-response-updated/40f51cf2-1829-4b30-8926-79f28f35398e?srid=116&sruid=windpioneers%2Fpower-loss-service%3A0.20.1
Where the important bit is a duplicated // from concatenating a base url.
Proposed Solution
An rstrip('/') should be added when concatenating the base url in events/utils.py
def get_event_url(event_kind, event_reference, event_parameters=None, url_namespace="gcp-events", base_url=None):
    """Returns a fully constructed url for the events endpoint, suitable for receipt and processing of events
    :param str event_kind: The kind of the event (must be url-safe)
    :param str event_reference: A reference allowing either identification of unique events or a group of related events (must be url-safe)
    :param Union[dict, None] event_parameters: Dict of additional parameters to encode into the URL querystring, for example use {"token": "abc"} to add a token parameter that gets received by the endpoint.
    :param str url_namespace: Default 'gcp-events'. URL namespace of the django-gcp events (see https://docs.djangoproject.com/en/4.0/topics/http/urls/#url-namespaces)
    :param Union[str, None] base_url: The base url (eg https://somewhere.com) for the URL. By default, this uses django's BASE_URL setting. To generate an empty value (a relative URL) use an empty string ''.
    :return str: The fully constructed webhook endpoint
    """
    url = reverse(url_namespace, args=[event_kind, event_reference])
    if event_parameters is not None:
        url = url + "?" + urlencode(event_parameters)
    if base_url is None:
        try:
            base_url = settings.BASE_URL
        except AttributeError as e:
            raise AttributeError(
                "Either specify BASE_URL in your settings module, or explicitly pass a base_url parameter to get_push_endpoint()"
            ) from e
    url = base_url + url
    logger.debug("Generated webhook endpoint url %s", url)
    return url
Metadata
Metadata
Assignees
Labels
bugUnintended behaviour in any area of the appUnintended behaviour in any area of the app
Type
Projects
Status
No status