mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor(site): drop redundant window. prefix on browser globals (#24500)
This commit is contained in:
@@ -138,7 +138,7 @@ export const getAppHref = (
|
||||
}
|
||||
|
||||
if (host && app.subdomain && app.subdomain_name) {
|
||||
const baseUrl = `${window.location.protocol}//${host.replace(/\*/g, app.subdomain_name)}`;
|
||||
const baseUrl = `${location.protocol}//${host.replace(/\*/g, app.subdomain_name)}`;
|
||||
const url = new URL(baseUrl);
|
||||
url.pathname = "/";
|
||||
return url.toString();
|
||||
|
||||
@@ -335,7 +335,7 @@ const UserSettingsSub: FC<UserSettingsSubProps> = ({
|
||||
|
||||
export const includeOrigin = (target: string): string => {
|
||||
if (target.startsWith("/")) {
|
||||
const baseUrl = window.location.origin;
|
||||
const baseUrl = location.origin;
|
||||
return `${baseUrl}${target}`;
|
||||
}
|
||||
return target;
|
||||
|
||||
@@ -236,7 +236,7 @@ const TaskSidebarMenuItem: FC<TaskSidebarMenuItemProps> = ({ task }) => {
|
||||
<RouterLink
|
||||
to={{
|
||||
pathname: `/tasks/${task.owner_name}/${task.id}`,
|
||||
search: window.location.search,
|
||||
search: location.search,
|
||||
}}
|
||||
>
|
||||
<TaskSidebarMenuItemStatus task={task} />
|
||||
|
||||
@@ -65,7 +65,7 @@ export const TemplateFiles: FC<TemplateFilesProps> = ({
|
||||
<TemplateFileTree
|
||||
fileTree={fileTree}
|
||||
onSelect={(path: string) => {
|
||||
window.location.hash = path;
|
||||
location.hash = path;
|
||||
document.getElementById(path)?.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "start",
|
||||
|
||||
@@ -195,7 +195,7 @@ const RefreshSessionButton: FC = () => {
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setIsRefreshing(true);
|
||||
window.location.reload();
|
||||
location.reload();
|
||||
}}
|
||||
>
|
||||
<RefreshCwIcon className={cn(isRefreshing && "animate-spin")} />
|
||||
|
||||
Reference in New Issue
Block a user