Skip to content

Commit a3dc917

Browse files
authored
fix(abc:lodop): support URL with parameters (#1824)
1 parent 40ae0dc commit a3dc917

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

packages/abc/lodop/lodop.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class LodopService implements OnDestroy {
2121

2222
constructor(configSrv: AlainConfigService) {
2323
this.defaultConfig = configSrv.merge('lodop', {
24-
url: '//localhost:8443/CLodopfuncs.js',
24+
url: 'http://localhost:8443/CLodopfuncs.js',
2525
name: 'CLODOP',
2626
companyName: '',
2727
checkMaxCount: 100
@@ -88,8 +88,10 @@ export class LodopService implements OnDestroy {
8888

8989
private request(): void {
9090
this.pending = true;
91+
const urlObj = new URL(this.cog.url!);
92+
urlObj.searchParams.set('name', this.cog.name!);
93+
const url = urlObj.toString();
9194

92-
const url = `${this.cog.url}?name=${this.cog.name}`;
9395
let checkMaxCount = this.cog.checkMaxCount as number;
9496
const onResolve = (status: NzSafeAny, error?: NzSafeAny): void => {
9597
this._init.next({

packages/abc/lodop/lodop.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ describe('abc: lodop', () => {
163163
});
164164
srv.reset();
165165
});
166+
it('should be custom url', () => {
167+
const url = 'http://a.com/lodop.js?aa=1';
168+
cog.lodop!.url = url;
169+
genModule();
170+
const scriptSrv = (srv as NzSafeAny).scriptSrv;
171+
spyOn(scriptSrv, 'loadScript').and.callFake(() => Promise.resolve({ status: 'ok' }));
172+
srv.reset();
173+
expect(scriptSrv.loadScript).toHaveBeenCalled();
174+
expect(scriptSrv.loadScript.calls.first().args[0]).toBe(`${url}&name=LODOP`);
175+
});
166176
});
167177

168178
describe('#attachCode', () => {

packages/util/config/abc/lodop.type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export interface AlainLodopConfig {
1818
/**
1919
* Lodop 远程脚本URL地址,**注意**务必使用 `name` 属性指定变量值
2020
*
21-
* - http://localhost:18000/CLodopfuncs.js
22-
* - https://localhost:8443/CLodopfuncs.js [默认]
21+
* - http://localhost:18000/CLodopfuncs.js [默认]
22+
* - https://localhost:8443/CLodopfuncs.js
2323
*/
2424
url?: string;
2525
/**

0 commit comments

Comments
 (0)