@@ -64,6 +64,8 @@ import { testing } from "../test-api.js";
6464import { createParallelWebSearchProvider as createContractParallelWebSearchProvider } from "../web-search-contract-api.js" ;
6565import { createParallelWebSearchProvider } from "./parallel-web-search-provider.js" ;
6666
67+ const loneHighSurrogate = / [ \uD800 - \uDBFF ] (? ! [ \uDC00 - \uDFFF ] ) / ;
68+
6769describe ( "parallel web search provider" , ( ) => {
6870 beforeEach ( ( ) => {
6971 endpointMockState . calls = [ ] ;
@@ -254,6 +256,9 @@ describe("parallel web search provider", () => {
254256 expect ( testing . normalizeParallelObjective ( undefined ) ) . toBeUndefined ( ) ;
255257 expect ( testing . normalizeParallelObjective ( "" ) ) . toBeUndefined ( ) ;
256258 expect ( ( testing . normalizeParallelObjective ( "x" . repeat ( 6000 ) ) ?? "" ) . length ) . toBe ( 5000 ) ;
259+ const boundary = testing . normalizeParallelObjective ( `${ "x" . repeat ( 4999 ) } \u{1f63e}tail` ) ;
260+ expect ( boundary ) . toBe ( "x" . repeat ( 4999 ) ) ;
261+ expect ( loneHighSurrogate . test ( boundary ?? "" ) ) . toBe ( false ) ;
257262 } ) ;
258263
259264 it ( "normalizes search_queries: trim, drop blanks, dedupe, cap length, cap count" , ( ) => {
@@ -270,6 +275,14 @@ describe("parallel web search provider", () => {
270275 expect ( testing . normalizeParallelSearchQueries ( undefined ) ) . toEqual ( [ ] ) ;
271276 expect ( testing . normalizeParallelSearchQueries ( "openclaw github" ) ) . toEqual ( [ ] ) ;
272277 expect ( testing . normalizeParallelSearchQueries ( [ "x" . repeat ( 250 ) ] ) ) . toEqual ( [ "x" . repeat ( 200 ) ] ) ;
278+ expect ( testing . normalizeParallelSearchQueries ( [ `${ "x" . repeat ( 199 ) } \u{1f63e}tail` ] ) ) . toEqual ( [
279+ "x" . repeat ( 199 ) ,
280+ ] ) ;
281+ expect (
282+ loneHighSurrogate . test (
283+ testing . normalizeParallelSearchQueries ( [ `${ "x" . repeat ( 199 ) } \u{1f63e}tail` ] ) [ 0 ] ?? "" ,
284+ ) ,
285+ ) . toBe ( false ) ;
273286 const six = [ "a" , "b" , "c" , "d" , "e" , "f" ] ;
274287 expect ( testing . normalizeParallelSearchQueries ( six ) ) . toEqual ( [ "a" , "b" , "c" , "d" , "e" ] ) ;
275288 } ) ;
@@ -289,6 +302,9 @@ describe("parallel web search provider", () => {
289302 expect ( testing . normalizeParallelClientModel ( " gpt-5.5 " ) ) . toBe ( "gpt-5.5" ) ;
290303 expect ( testing . normalizeParallelClientModel ( undefined ) ) . toBeUndefined ( ) ;
291304 expect ( ( testing . normalizeParallelClientModel ( "a" . repeat ( 200 ) ) ?? "" ) . length ) . toBe ( 100 ) ;
305+ const boundary = testing . normalizeParallelClientModel ( `${ "m" . repeat ( 99 ) } \u{1f63e}tail` ) ;
306+ expect ( boundary ) . toBe ( "m" . repeat ( 99 ) ) ;
307+ expect ( loneHighSurrogate . test ( boundary ?? "" ) ) . toBe ( false ) ;
292308 } ) ;
293309
294310 it ( "normalizes the Parallel /v1/search response shape" , ( ) => {
0 commit comments