Skip to content
Open
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
14 changes: 8 additions & 6 deletions modules/imuIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import { timestamp, logError } from '../src/utils.js';
import { ajax } from '../src/ajax.js'
import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
import { getStorageManager } from '../src/storageManager.js';
import { MODULE_TYPE_UID } from '../src/activities/modules.js';
import { getRefererInfo } from '../src/refererDetection.js';

/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
Expand Down Expand Up @@ -57,10 +58,11 @@ export function getLocalData() {
}

export function getApiUrl(cid, url) {
if (url) {
return `${url}?cid=${cid}`;
}
return `https://${apiDomain}/${cid}/pid`;
const baseUrl = url ? `${url}?cid=${cid}&` : `https://${apiDomain}/${cid}/pid?`;
const refererInfo = getRefererInfo();
return baseUrl +
`page=${encodeURIComponent(refererInfo.page || '')}` +
`&ref=${encodeURIComponent(refererInfo.ref || '')}`;
Comment on lines +61 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいのですが page が空なときに &&ref とか ?&ref になっちゃってカッコ悪いなぁと思ってしまい・・

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fecker san

細かいのですが page が空なときに &&ref とか ?&ref になっちゃってカッコ悪いなぁと思ってしまい・・

page が空の時には ?page=&ref=xxxx って感じになりますね(記号だけ残る感じにはならないです!)
page= のところも消したい感じですかね?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あー、ボケてますね・・・
できればパラメータごと消したかったのですが、特にこれなら問題ないかなと思ったのでいっちゃいましょう。

}

export function apiSuccessProcess(jsonResponse) {
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/imuIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ describe('imuId module', function () {
describe('getApiUrl()', function () {
it('should return default url when cid only', function () {
const url = getApiUrl(5126);
expect(url).to.be.equal(`https://sync6.im-apps.net/5126/pid`);
expect(url).to.be.match(/^https:\/\/sync6.im-apps.net\/5126\/pid\?page=.+&ref=$/);
});

it('should return param url when set url', function () {
const url = getApiUrl(5126, 'testurl');
expect(url).to.be.equal('testurl?cid=5126');
expect(url).to.be.match(/^testurl\?cid=5126&page=.+&ref=$/);
});
});

Expand Down
Loading