-
-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add '--noStripTrailingSlashInUrl' option
- Loading branch information
1 parent
0a5ded7
commit e9695ec
Showing
8 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict' | ||
|
||
exports.echo = async (event) => { | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
path: event.path, | ||
resource: event.resource, | ||
}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
service: uncategorized-tests | ||
|
||
plugins: | ||
- ../../../ | ||
|
||
provider: | ||
memorySize: 128 | ||
name: aws | ||
region: us-east-1 # default | ||
runtime: nodejs12.x | ||
stage: dev | ||
versionFunctions: false | ||
|
||
functions: | ||
echo: | ||
handler: handler.echo | ||
events: | ||
- http: | ||
method: get | ||
path: /echo/test | ||
- http: | ||
method: get | ||
path: /echo/test/ | ||
- http: | ||
method: get | ||
path: /echo/{any+} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { resolve } from 'path' | ||
import fetch from 'node-fetch' | ||
import { | ||
joinUrl, | ||
setup, | ||
teardown, | ||
} from '../../integration/_testHelpers/index.js' | ||
|
||
jest.setTimeout(30000) | ||
|
||
describe('noStripTrailingSlashInUrl option', () => { | ||
// init | ||
beforeAll(() => | ||
setup({ | ||
servicePath: resolve(__dirname), | ||
args: ['--noStripTrailingSlashInUrl'], | ||
}), | ||
) | ||
|
||
// cleanup | ||
afterAll(() => teardown()) | ||
|
||
describe('when --noStripTrailingSlashInUrl is used, and request is made ending with slash', () => { | ||
test('it should not be removed', async () => { | ||
const url = joinUrl(TEST_BASE_URL, '/dev/echo/something/') | ||
const response = await fetch(url) | ||
const json = await response.json() | ||
|
||
expect(json).toEqual({ | ||
path: '/echo/something/', | ||
resource: '/echo/{any*}', | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when --noStripTrailingSlashInUrl is used, events with and without slash can co-exist', () => { | ||
test('it should not be removed', async () => { | ||
let url = joinUrl(TEST_BASE_URL, '/dev/echo/test') | ||
let response = await fetch(url) | ||
let json = await response.json() | ||
expect(json).toEqual({ | ||
path: '/echo/test', | ||
resource: '/echo/test', | ||
}) | ||
|
||
url = joinUrl(TEST_BASE_URL, '/dev/echo/test/') | ||
response = await fetch(url) | ||
json = await response.json() | ||
expect(json).toEqual({ | ||
path: '/echo/test/', | ||
resource: '/echo/test/', | ||
}) | ||
}) | ||
}) | ||
}) |