File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { EngineParameters } from "./types.ts";
22import { version } from "../version.ts" ;
33import https from "node:https" ;
44import qs from "node:querystring" ;
5+ import url from "node:url" ;
56import { RequestTimeoutError } from "./errors.ts" ;
67import { EngineMap } from "./engines/engine_map.ts" ;
78
@@ -30,16 +31,21 @@ type NextParameters<E extends keyof EngineMap> = {
3031 >
3132 ] : string ;
3233} ;
33- export function extractNextParameters < E extends keyof EngineMap > ( json : {
34- serpapi_pagination ?: { next : string } ;
35- pagination ?: { next : string } ;
36- } ) {
34+ export function extractNextParameters < E extends keyof EngineMap > (
35+ json : {
36+ serpapi_pagination ?: { next : string } ;
37+ pagination ?: { next : string } ;
38+ } ,
39+ ) {
3740 const nextUrlString = json [ "serpapi_pagination" ] ?. [ "next" ] ||
3841 json [ "pagination" ] ?. [ "next" ] ;
3942
4043 if ( nextUrlString ) {
41- const nextUrl = new URL ( nextUrlString ) ;
42- const nextParameters = Object . fromEntries ( nextUrl . searchParams . entries ( ) ) ;
44+ const nextUrl = new url . URL ( nextUrlString ) ;
45+ const nextParameters : Record < string , string > = { } ;
46+ for ( const [ k , v ] of nextUrl . searchParams . entries ( ) ) {
47+ nextParameters [ k ] = v ;
48+ }
4349 return nextParameters as NextParameters < E > ;
4450 }
4551}
You can’t perform that action at this time.
0 commit comments