Skip to content
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

fix(http): remove dots from jsonp callback name #13219

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/@angular/http/src/backends/browser_jsonp.ts
Expand Up @@ -32,23 +32,23 @@ export class BrowserJsonp {

nextRequestID(): string { return `__req${_nextRequestId++}`; }

requestCallback(id: string): string { return `${JSONP_HOME}.${id}.finished`; }
requestCallback(id: string): string { return `${JSONP_HOME}${id}_finished`; }

exposeConnection(id: string, connection: any) {
exposeConnection(id: string, connection: any): void {
const connections = _getJsonpConnections();

Choose a reason for hiding this comment

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

Is there any problems with _getJsonpConnections()? if it will throw ${JSONP_HOME}${id}_finished is undefined.

connections[id] = connection;
}

removeConnection(id: string) {
removeConnection(id: string): void {
const connections = _getJsonpConnections();
connections[id] = null;
}

// Attach the <script> element to the DOM
send(node: any) { document.body.appendChild(<Node>(node)); }
send(node: any): void { document.body.appendChild(<Node>(node)); }

// Remove <script> element from the DOM
cleanup(node: any) {
cleanup(node: any): void {
if (node.parentNode) {
node.parentNode.removeChild(<Node>(node));
}
Expand Down
5 changes: 5 additions & 0 deletions modules/@angular/http/test/backends/jsonp_backend_spec.ts
Expand Up @@ -70,6 +70,11 @@ export function main() {
expect(instance).toBeAnInstanceOf(JSONPConnection);
});

it('callback name should not contain dots', () => {
const domJsonp = new MockBrowserJsonp();
const callback: string = domJsonp.requestCallback(domJsonp.nextRequestID());
expect(callback.indexOf('.') === -1).toBeTruthy();
});

describe('JSONPConnection', () => {
it('should use the injected BaseResponseOptions to create the response',
Expand Down