Strip trailing slash on openapi import base_url env

This commit is contained in:
Gregory Schier committed 2020-01-24 14:07:52 -05:00
1 parent 7b3ae5bfd8
commit 9b39fbf36f
2 files changed
+6 -2

No files matched your search

@@ -19,7 +19,7 @@
},
"servers": [
{
"url": "http://petstore.swagger.io/v2"
"url": "http://petstore.swagger.io/v2/"
}
],
"tags": [],
@@ -67,6 +67,10 @@ module.exports.convert = async function(rawData) {
);
const protocol = defaultServer.protocol || '';
// Base path is pulled out of the URL, and the trailing slash is removed
const basePath = (defaultServer.pathname || '').replace(/\/$/, '');
const openapiEnv = {
_type: 'environment',
_id: `env___BASE_ENVIRONMENT_ID___sub`,
@@ -75,7 +79,7 @@ module.exports.convert = async function(rawData) {
data: {
// note: `URL.protocol` returns with trailing `:` (i.e. "https:")
scheme: protocol.replace(/:$/, '') || ['http'],
base_path: defaultServer.pathname || '',
base_path: basePath,
host: defaultServer.host || '',
...securityVariables,
},