17 lines
565 B
TypeScript
17 lines
565 B
TypeScript
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
export function getParameterByName(name: string) {
|
|
const url = window.location.href;
|
|
name = name.replace(/[\[\]]/g, "\\$&");
|
|
const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
|
|
const results = regex.exec(url);
|
|
if (!results) {
|
|
return null;
|
|
}
|
|
if (!results[2]) {
|
|
return "";
|
|
}
|
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
}
|