@@ -3,6 +3,7 @@ import request from 'supertest';
3
3
import type { BaseHttpServerFactory } from '../../src/server/BaseHttpServerFactory' ;
4
4
import type { HttpHandlerInput } from '../../src/server/HttpHandler' ;
5
5
import { HttpHandler } from '../../src/server/HttpHandler' ;
6
+ import { splitCommaSeparated } from '../../src/util/StringUtil' ;
6
7
import { getPort } from '../util/Util' ;
7
8
import { getTestConfigPath , instantiateFromConfig } from './Config' ;
8
9
@@ -96,46 +97,46 @@ describe('An http server with middleware', (): void => {
96
97
it ( 'exposes the Accept-[Method] header via CORS.' , async ( ) : Promise < void > => {
97
98
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
98
99
const exposed = res . header [ 'access-control-expose-headers' ] ;
99
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Accept-Patch' ) ;
100
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Accept-Post' ) ;
101
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Accept-Put' ) ;
100
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Accept-Patch' ) ;
101
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Accept-Post' ) ;
102
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Accept-Put' ) ;
102
103
} ) ;
103
104
104
105
it ( 'exposes the Last-Modified and ETag headers via CORS.' , async ( ) : Promise < void > => {
105
106
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
106
107
const exposed = res . header [ 'access-control-expose-headers' ] ;
107
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'ETag' ) ;
108
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Last-Modified' ) ;
108
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'ETag' ) ;
109
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Last-Modified' ) ;
109
110
} ) ;
110
111
111
112
it ( 'exposes the Link header via CORS.' , async ( ) : Promise < void > => {
112
113
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
113
114
const exposed = res . header [ 'access-control-expose-headers' ] ;
114
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Link' ) ;
115
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Link' ) ;
115
116
} ) ;
116
117
117
118
it ( 'exposes the Location header via CORS.' , async ( ) : Promise < void > => {
118
119
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
119
120
const exposed = res . header [ 'access-control-expose-headers' ] ;
120
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Location' ) ;
121
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Location' ) ;
121
122
} ) ;
122
123
123
124
it ( 'exposes the MS-Author-Via header via CORS.' , async ( ) : Promise < void > => {
124
125
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
125
126
const exposed = res . header [ 'access-control-expose-headers' ] ;
126
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'MS-Author-Via' ) ;
127
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'MS-Author-Via' ) ;
127
128
} ) ;
128
129
129
130
it ( 'exposes the WAC-Allow header via CORS.' , async ( ) : Promise < void > => {
130
131
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
131
132
const exposed = res . header [ 'access-control-expose-headers' ] ;
132
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'WAC-Allow' ) ;
133
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'WAC-Allow' ) ;
133
134
} ) ;
134
135
135
136
it ( 'exposes the Updates-Via header via CORS.' , async ( ) : Promise < void > => {
136
137
const res = await request ( server ) . get ( '/' ) . expect ( 200 ) ;
137
138
const exposed = res . header [ 'access-control-expose-headers' ] ;
138
- expect ( exposed . split ( / \s * , \s * / u ) ) . toContain ( 'Updates-Via' ) ;
139
+ expect ( splitCommaSeparated ( exposed ) ) . toContain ( 'Updates-Via' ) ;
139
140
} ) ;
140
141
141
142
it ( 'sends incoming requests to the handler.' , async ( ) : Promise < void > => {
0 commit comments