Skip to content

Commit 410892f

Browse files
committed
fix: refactor URL handling in getURLParameterValue and _getList functions for improved clarity and functionality
1 parent 7760f9d commit 410892f

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

Project/Sources/Classes/Tools.4dm

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,27 +266,14 @@ Function getPortFromURL($inURL : Text) : Integer
266266
// ----------------------------------------------------
267267

268268

269-
Function getURLParameterValue($URL : Text; $paramName : Text) : Text
269+
Function getURLParameterValue($inURL : Text; $inParamName : Text) : Text
270270

271-
var $result : Text
272-
var $posQuery : Integer:=Position("?"; $URL)
273-
If ($posQuery>0)
274-
275-
var $queryString : Text:=Substring($URL; $posQuery+1)
276-
var $parameters : Collection:=Split string($queryString; "&"; sk ignore empty strings)
277-
var $parameter : Text
278-
279-
For each ($parameter; $parameters)
280-
281-
var $values : Collection:=Split string($parameter; "=")
282-
283-
If ($values.length=2)
284-
If ($values[0]=$paramName)
285-
$result:=$values[1]
286-
break
287-
End if
288-
End if
289-
End for each
271+
var $result : Text:=""
272+
var $URL : cs.URL:=cs.URL.new($inURL)
273+
var $foundParam : Object:=$URL.queryParams.find(Formula($1.value.name=$2); $inParamName)
274+
275+
If ((Value type($foundParam)=Is object) && (OB Is defined($foundParam; "value")))
276+
$result:=$foundParam.value
290277
End if
291278

292279
return $result
@@ -582,7 +569,7 @@ Function makeError($inCode : Integer; $inParameters : Object) : Object
582569

583570

584571
Function buildPageFromTemplate($inTitle : Text; $inMessage : Text; $inDetails : Text; $inButtonText : Text) : Text
585-
/*
572+
/*
586573
Builds a response page from the template file.
587574
Parameters:
588575
- $inTitle: Title of the page

Project/Sources/Classes/_GoogleBaseList.4dm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ Class constructor($inProvider : cs.OAuth2Provider; $inParameters : Object)
3232

3333
Function _getList($inPageToken : Text) : Boolean
3434

35-
var $URL : Text:=This._internals._URL
35+
var $URL : cs.URL:=cs.URL.new(This._internals._URL)
3636

3737
If (Length(String($inPageToken))>0)
38-
39-
var $sep : Text:=((Position("?"; $URL)=0) ? "?" : "&")
40-
$URL+=$sep+"pageToken="+$inPageToken
38+
$URL.addQueryParameter("pageToken"; inPageToken)
4139
End if
4240

4341
Super._throwErrors(False)
44-
var $response : Object:=Super._sendRequestAndWaitResponse("GET"; $URL; This._internals._headers)
42+
var $response : Object:=Super._sendRequestAndWaitResponse("GET"; $URL.toString(); This._internals._headers)
4543
Super._throwErrors(True)
4644

4745
This.isLastPage:=False

0 commit comments

Comments
 (0)