Skip to content

Commit

Permalink
fix links.related in case of url params
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaxxl committed Jul 23, 2023
1 parent 0f80b66 commit 8735f73
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions safrs/jsonapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from flask_restful_swagger_2 import Resource as FRSResource
from http import HTTPStatus
from sqlalchemy.orm.interfaces import MANYTOONE
from urllib.parse import urljoin
from .swagger_doc import is_public
from .errors import ValidationError, NotFoundError
from .jsonapi_formatting import jsonapi_filter_query, jsonapi_filter_list, jsonapi_sort, jsonapi_format_response, paginate
Expand Down Expand Up @@ -266,8 +267,8 @@ def get(self, **kwargs):
count = 1
if instance is not None:
links = {"self": instance._s_url}
if request.url != instance._s_url:
links["related"] = request.url
if request.full_path.strip('?').strip('/') != instance._s_url.strip('?').strip('/'):
links["related"] = urljoin(instance._s_url_root, request.full_path)
meta.update(dict(instance_meta=instance._s_meta()))
else:
# retrieve a collection, filter and sort
Expand All @@ -278,7 +279,6 @@ def get(self, **kwargs):
# format the response: add the included objects
result = jsonapi_format_response(data, meta, links, errors, count)
return jsonify(result)
return make_response({})

def patch(self, **kwargs):
"""
Expand Down

0 comments on commit 8735f73

Please sign in to comment.