Skip to content

Commit

Permalink
[docs] Remove usage of url package (#27151)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jul 8, 2021
1 parent f86eb44 commit c6642e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/src/modules/components/AppSearch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import url from 'url';
import clsx from 'clsx';
import useLazyCSS from 'docs/src/modules/utils/useLazyCSS';
import useMediaQuery from '@material-ui/core/useMediaQuery';
Expand Down Expand Up @@ -200,7 +199,8 @@ export default function AppSearch() {
},
handleSelected: (input, event, suggestion) => {
event.button = 0;
const parseUrl = url.parse(suggestion.url);
const parseUrl = document.createElement('a');
parseUrl.href = suggestion.url;
handleEvent(event, parseUrl.pathname + parseUrl.hash);
input.close();
},
Expand Down
16 changes: 12 additions & 4 deletions docs/src/pages/customization/default-theme/DefaultTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import url from 'url';
import Box from '@material-ui/core/Box';
import ExpandIcon from '@material-ui/icons/ExpandMore';
import CollapseIcon from '@material-ui/icons/ChevronRight';
Expand Down Expand Up @@ -238,9 +237,18 @@ function DefaultTheme() {
const [darkTheme, setDarkTheme] = React.useState(false);

React.useEffect(() => {
const URL = url.parse(document.location.href, true);
// 'expend-path' is for backwards compatibility of any external links with a prior typo.
const expandPath = URL.query['expand-path'] || URL.query['expend-path'];
let expandPath;
decodeURI(document.location.search.slice(1))
.split('&')
.forEach((param) => {
const [name, value] = param.split('=');
if (name === 'expand-path') {
expandPath = value;
} else if (name === 'expend-path' && !expandPath) {
// 'expend-path' is for backwards compatibility of any external links with a prior typo.
expandPath = value;
}
});

if (!expandPath) {
return;
Expand Down

0 comments on commit c6642e3

Please sign in to comment.