File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change
1
+
2
+ # 0.8.0-rc.0 - 15 Dec 2023
3
+ Change:
4
+ - Add support for Elysia 0.8
5
+
1
6
# 0.7.2 - 14 Nov 2023
2
7
Bug fix:
3
8
- Response using origin instead of '* ' when presented
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @elysiajs/cors" ,
3
- "version" : " 0.8.0-rc.0 " ,
3
+ "version" : " 0.8.0-rc.1 " ,
4
4
"description" : " Plugin for Elysia that for Cross Origin Requests (CORs)" ,
5
5
"author" : {
6
6
"name" : " saltyAom" ,
Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-case-declarations */
1
2
import { Elysia , type Context } from 'elysia'
2
3
3
4
type Origin = string | RegExp | ( ( request : Request ) => boolean | void )
@@ -181,13 +182,15 @@ export const cors = (
181
182
const processOrigin = ( origin : Origin , request : Request , from : string ) => {
182
183
switch ( typeof origin ) {
183
184
case 'string' :
184
- // eslint-disable-next-line no-case-declarations
185
185
const protocolStart = from . indexOf ( '://' )
186
+ if ( protocolStart !== - 1 )
187
+ from = from . slice ( protocolStart + 3 )
186
188
187
- // Malform URL, invalid protocol
188
- if ( protocolStart === - 1 ) return false
189
+ const trailingSlash = from . indexOf ( '/' , 0 )
190
+ if ( trailingSlash !== - 1 )
191
+ from = from . slice ( trailingSlash )
189
192
190
- return origin === from . slice ( protocolStart + 3 )
193
+ return origin === from
191
194
192
195
case 'function' :
193
196
return origin ( request )
You can’t perform that action at this time.
0 commit comments