JSFiddle - React, Tailwind, and code Playground

by Vladimir Kutepov

CSS

b {
  color: red;
}

JavaScript

const r = /[^/]+$/
const test = [
  'http://localhost/path-to-page/some.html.page',
  'http://localhost/path-to-page/page.name.html',
  'http://localhost/path-to-page/page.name',
  'http://localhost/path-to-page/some-html-page',
  'http://localhost/path-to-page/page-name.html',
  'http://localhost/path-to-page/page-name',
  'http://localhost/path-to-page/html.page',
  'http://localhost/path-to-page/html-page',
  'http://localhost/path-to-page/',
]

const output = test.map(t => {
	const match = t.match(r)
  return match && match[0] ?
  	match[0].replace(/(\.html)$/, '<b>$1</b>') : ''
})
document.body.innerHTML = output.join('<br/>')