-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[monitor-query] Add version string to options endpoint (#23383)
- Loading branch information
1 parent
4f44c25
commit 15bfcd8
Showing
5 changed files
with
47 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
sdk/monitor/monitor-query/src/internal/logQueryOptionUtils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { LogsQueryClientOptions } from "../logsQueryClient"; | ||
|
||
export function getLogQueryEndpoint(options: LogsQueryClientOptions): string { | ||
if (!options.endpoint) { | ||
throw new Error("options.endpoint is required"); | ||
} | ||
|
||
const url = new URL(options.endpoint); | ||
url.pathname = "/v1"; | ||
|
||
return url.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
sdk/monitor/monitor-query/test/internal/unit/logQueryOptionUtils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { assert } from "@azure/test-utils"; | ||
import { getLogQueryEndpoint } from "../../../src/internal/logQueryOptionUtils"; | ||
|
||
describe("logQueryOptionsUtils", () => { | ||
describe("getLogQueryEndpoint", () => { | ||
it("should return the endpoint with the version", () => { | ||
const expected = "http://microsoft.com/v1"; | ||
|
||
const endpoint1 = "http://microsoft.com/"; | ||
const endpoint2 = "http://microsoft.com"; | ||
|
||
const result1 = getLogQueryEndpoint({ endpoint: endpoint1 }); | ||
const result2 = getLogQueryEndpoint({ endpoint: endpoint2 }); | ||
|
||
assert.equal(result1, expected); | ||
assert.equal(result2, expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters