@@ -618,16 +618,20 @@ def requestJsonAndCheck(
618618 :raises: :class:`GithubException` for error status codes
619619
620620 """
621- return self .__check (
622- * self .requestJson (
623- verb ,
624- url ,
625- parameters ,
626- headers ,
627- input ,
628- self .__customConnection (url ),
629- follow_302_redirect = follow_302_redirect ,
630- )
621+ return self .__postProcess (
622+ verb ,
623+ url ,
624+ * self .__check (
625+ * self .requestJson (
626+ verb ,
627+ url ,
628+ parameters ,
629+ headers ,
630+ input ,
631+ self .__customConnection (url ),
632+ follow_302_redirect = follow_302_redirect ,
633+ )
634+ ),
631635 )
632636
633637 def requestMultipartAndCheck (
@@ -647,7 +651,11 @@ def requestMultipartAndCheck(
647651 :raises: :class:`GithubException` for error status codes
648652
649653 """
650- return self .__check (* self .requestMultipart (verb , url , parameters , headers , input , self .__customConnection (url )))
654+ return self .__postProcess (
655+ verb ,
656+ url ,
657+ * self .__check (* self .requestMultipart (verb , url , parameters , headers , input , self .__customConnection (url ))),
658+ )
651659
652660 def requestBlobAndCheck (
653661 self ,
@@ -667,7 +675,11 @@ def requestBlobAndCheck(
667675 :raises: :class:`GithubException` for error status codes
668676
669677 """
670- return self .__check (* self .requestBlob (verb , url , parameters , headers , input , self .__customConnection (url )))
678+ return self .__postProcess (
679+ verb ,
680+ url ,
681+ * self .__check (* self .requestBlob (verb , url , parameters , headers , input , self .__customConnection (url ))),
682+ )
671683
672684 @classmethod
673685 def paths_of_dict (cls , d : dict ) -> dict :
@@ -851,6 +863,22 @@ def __check(
851863 raise self .createException (status , responseHeaders , data )
852864 return responseHeaders , data
853865
866+ def __postProcess (
867+ self , verb : str , url : str , responseHeaders : dict [str , Any ], data : Any
868+ ) -> tuple [dict [str , Any ], Any ]:
869+ if verb == "GET" and isinstance (data , dict ) and "url" not in data :
870+ if "_links" in data and "self" in data ["_links" ] and data ["_links" ]["self" ]:
871+ self_link = data ["_links" ]["self" ]
872+ if isinstance (self_link , str ):
873+ data ["url" ] = self_link
874+ elif isinstance (self_link , dict ):
875+ href = self_link .get ("href" )
876+ if href :
877+ data ["url" ] = href
878+ else :
879+ data ["url" ] = url
880+ return responseHeaders , data
881+
854882 @classmethod
855883 def __hostnameHasDomain (cls , hostname : str , domain_or_domains : str | list [str ]) -> bool :
856884 if isinstance (domain_or_domains , str ):
@@ -1143,7 +1171,7 @@ def encode(_: Any) -> tuple[str, Any]:
11431171
11441172 status , responseHeaders , output = self .__requestEncode (cnx , verb , url , parameters , headers , file_like , encode )
11451173 if isinstance (output , str ):
1146- return self .__check (status , responseHeaders , output )
1174+ return self .__postProcess ( verb , url , * self . __check (status , responseHeaders , output ) )
11471175 raise ValueError ("requestMemoryBlobAndCheck() Expected a str, should never happen" )
11481176
11491177 def __requestEncode (
0 commit comments