Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4039810

Browse files
authored
Fix replacing host from environment variable AWS_ENDPOINT_URL (#238)
1 parent2a3384d commit4039810

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

‎spec/unit/index.spec.js‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,28 @@ describe("LocalstackPlugin", () => {
177177
expect(request.called).to.be.true;
178178
lettemplateUrl=request.firstCall.args[2].TemplateURL;
179179
// url should either start with 'http://localhost' or 'http://127.0.0.1
180-
expect(templateUrl).to.satisfy((url)=>url.startsWith(`${config.host}`)||url.startsWith('http://127.0.0.1'));
180+
expect(templateUrl).to.satisfy((url)=>url===`${config.host}:4566/path/to/template`||url==='http://127.0.0.1:4566/path/to/template');
181+
});
182+
183+
it('should overwrite the S3 hostname with the value from environment variable',async()=>{
184+
// Set environment variable to overwrite the default host
185+
process.env.AWS_ENDPOINT_URL='http://localstack:4566';
186+
187+
constpathToTemplate='https://s3.amazonaws.com/path/to/template';
188+
constrequest=sinon.stub(awsProvider,'request');
189+
instance=newLocalstackPlugin(serverless,defaultPluginState);
190+
awaitsimulateBeforeDeployHooks(instance);
191+
192+
awaitawsProvider.request('s3','foo',{
193+
TemplateURL:pathToTemplate
194+
});
195+
196+
// Remove the environment variable again to not affect other tests
197+
deleteprocess.env.AWS_ENDPOINT_URL
198+
199+
expect(request.called).to.be.true;
200+
lettemplateUrl=request.firstCall.args[2].TemplateURL;
201+
expect(templateUrl).to.equal('http://localstack:4566/path/to/template');
181202
});
182203

183204
it('should not send validateTemplate calls to localstack',async()=>{

‎src/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ class LocalstackPlugin {
784784
if(hostname&&url.hostname==='localhost'){
785785
url.hostname=hostname;
786786
}
787-
returnurl.href;
787+
returnurl.origin;
788788
}
789789

790790
log(msg){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp