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

[main] remove double slash for endPointUrl #2174

Merged
merged 3 commits into from
Oct 13, 2023
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
6 changes: 5 additions & 1 deletion shared/AppInsightsCommon/src/ConnectionStringParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { arrReduce, objKeys } from "@microsoft/applicationinsights-core-js";
import { arrReduce, objKeys, strEndsWith } from "@microsoft/applicationinsights-core-js";
import { DEFAULT_BREEZE_ENDPOINT } from "./Constants";
import { ConnectionString, ConnectionStringKey } from "./Interfaces/ConnectionString";

Expand Down Expand Up @@ -37,6 +37,10 @@ export function parseConnectionString(connectionString?: string): ConnectionStri

// apply the default endpoints
result.ingestionendpoint = result.ingestionendpoint || DEFAULT_BREEZE_ENDPOINT;

if (strEndsWith(result.ingestionendpoint, "/")) {
result.ingestionendpoint = result.ingestionendpoint.slice(0,-1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably should also do this for the snippet as well, although we won't be able to use strEndsWith in the snippet or the string endsWith as it's not supported on IE and the snippet needs to work for IE :-(.

nit: I don't normally use slice on strings, but it works for this case and it's available on all browsers.

}
}

return result;
Expand Down
3 changes: 3 additions & 0 deletions tools/applicationinsights-web-snippet/src/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ declare var cfg:ISnippetConfig;
let conString = _parseConnectionString();
let iKey = conString[strConStringIKey] || aiConfig[strInstrumentationKey] || strEmpty;
let ingest = conString[strIngestionendpoint];
if (ingest && ingest.slice(-1) === "/"){
ingest = ingest.slice(0,-1);
}
let endpointUrl = ingest ? ingest + "/v2/track" : aiConfig.endpointUrl; // only add /v2/track when from connectionstring

let message = "SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)";
Expand Down
Loading