Skip to content

Commit a0c5874

Browse files
committed
【feature】online 地图 withcredentials 优化
1 parent fffdcfa commit a0c5874

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/common/_utils/WebMapService.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,10 @@ export default class WebMapService extends Events {
10101010
return proxy;
10111011
}
10121012

1013-
public handleWithCredentials(proxyUrl?: string, serviceUrl?: string, defaultValue = this.withCredentials): boolean {
1013+
public handleWithCredentials(proxyUrl?: string, serviceUrl?: string, defaultValue = this.withCredentials): boolean | string {
1014+
if (serviceUrl?.includes('https://www.supermapol.com')) {
1015+
return '';
1016+
}
10141017
if (proxyUrl && proxyUrl.startsWith(this.serverUrl) && (!serviceUrl || serviceUrl.startsWith(proxyUrl))) {
10151018
return true;
10161019
}

src/common/_utils/__tests__/WebMapService.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -749,4 +749,17 @@ describe('WebMapService.spec', () => {
749749
const service = new WebMapService(mapId, options);
750750
expect(service.getDatasourceType(layer)).toBe('user_data');
751751
});
752+
753+
it('handleWithCredentials', () => {
754+
const mapId = uniqueLayer_polygon;
755+
const service = new WebMapService(mapId, { ...options, iportalServiceProxyUrlPrefix: 'https://fakeiportal.supermap.io/portalproxy' });
756+
expect(service.handleWithCredentials(null, 'https://www.supermapol.com/url', true)).toBe('');
757+
const url = 'http://fakeurl';
758+
expect(service.handleWithCredentials('https://fakeiportal.supermap.io/iportal/proxy', null, false)).toBeTruthy();
759+
expect(service.handleWithCredentials('https://fakeiportal.supermap.io/iportal/proxy', 'https://fakeiportal.supermap.io/iportal/proxy/url', false)).toBeTruthy();
760+
expect(service.handleWithCredentials('https://fakeiportal/proxy', null, true)).toBeTruthy();
761+
expect(service.handleWithCredentials(null, 'https://fakeiportal.supermap.io/portalproxy/url', false)).toBeTruthy();
762+
expect(service.handleWithCredentials(null, url, true)).toBeTruthy();
763+
expect(service.handleWithCredentials(null, url)).toBeFalsy();
764+
});
752765
});

0 commit comments

Comments
 (0)