8000 Bug fix getAddress util when path is empty, port swap with path by idanilt · Pull Request #275 · scalecube/scalecube-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bug fix getAddress util when path is empty, port swap with path #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export interface Endpoints {
export function minimized(endpoints: MicroserviceApi.Endpoint[]): Endpoints {
const res: Endpoints = {};
endpoints.forEach((e) => {
res[getFullAddress(e.address)] = res[getFullAddress(e.address)] || {};
res[getFullAddress(e.address)][e.serviceName] = res[getFullAddress(e.address)][e.serviceName] || {};
res[getFullAddress(e.address)][e.serviceName][e.methodName] = sAsyncModel[e.asyncModel];
const addr = getFullAddress(e.address);
res[addr] = res[addr] || {};
res[addr][e.serviceName] = res[getFullAddress(e.address)][e.serviceName] || {};
res[addr][e.serviceName][e.methodName] = sAsyncModel[e.asyncModel];
});
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ describe('endpointsUtil', () => {
path: 'B',
},
},
{
qualifier: 'GreetingService/greet$',
serviceName: 'GreetingService',
methodName: 'greet$',
asyncModel: 'requestStream' as AsyncModel,
address: {
protocol: 'pm',
host: 'defaultHost',
port: 1234,
path: '',
},
},
];

expect(endpoints).toEqual(restore(minimized(endpoints)));
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const buildAddress = ({
key: string;
}) => {
let [v1, rest]: any = str.split(delimiter);
if (!rest) {
if (rest === undefined) {
rest = v1;
v1 = optionalValue;
}
Expand Down
15 changes: 15 additions & 0 deletions packages/utils/tests/address.spec.ts
6B54
Original file line numberDiff line number Diff line change
Expand Up @@ -178,4 +178,19 @@ describe('Test address', () => {
})
);
});
test(`
Given a string 'ws://localhost:1234'
When calling getAddress with the given string
Then result will matching address object
`, () => {
const address = getAddress('ws://localhost:1234/');
expect(address).toMatchObject(
expect.objectContaining({
protocol: 'ws',
path: '',
host: 'localhost',
port: 1234,
})
);
});
});
0