Add class to specific pages?

  • 0
    how to write url strict before and floating after

    if (document.location.pathname == '/page/....(различные генерируемые страницы где добавляем класс).....')
    JavaScript Anonymous, Jul 24, 2019

  • 1 Answers
  • 0
    Some kind of incoherent question. Well, let's say this:

    const urls = [

    for (const url of urls ) {
    const expression = /^\/page\/(.*)?(article)(.*)?$/g;

    console.log(url, expression.test(url));
    '/page/profile' false
    '/page/article/123123' true
    '/page/article/new' true
    '/page/article' true
    '/page/some/nested/structure/here' false
    '/page/module/article/new' true

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!