Skip to content

Commit

Permalink
Fix issue with html in page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanhogan committed Jul 12, 2020
1 parent 1207583 commit aac0464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { compose } from 'redux'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { fetchPage } from '../../lib/api'
import { stripTags } from '../../lib/html'
import { addTab } from '../../store/tabs'

import Loading from '../loading'
Expand Down Expand Up @@ -37,7 +38,7 @@ class Page extends Component {

return fetchPage(title)
.then(({ title, content, sections }) => {
document.title = `${title} - Wikipadia`
document.title = `${stripTags(title)} - Wikipadia`

this.setState(
{
Expand Down
2 changes: 2 additions & 0 deletions src/lib/html/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const stripTags = string =>
string.replace(/<\/?[^>]+(>|$)/g, '')

0 comments on commit aac0464

Please sign in to comment.