Git Product home page Git Product logo

phpwa-doc's Issues

Clarifiy regex in docs

At first, I thought the regex documentation was wrong, and started to fix it:

| regex | Matches the regex |

  • regex: |/image/.*|
  • regex: {.jp(e)?g$}i
|

Although slash is a common character to use to enclose a regular expression, the examples above show using other characters to avoid needing to escape the slashes in the path. So //articles/./ is the same regex as {/articles/.}. See Regular Expressions for more information. Internally, regeg: maps to new RegExp()

But then when I dug into the code, I see that the new RegExp() format doesn't need the regex to be surrounded. I think this needs to be clearer, especially since when I see something like this:

startsWith: /dashboard
regex: /articles/
regex: |/articles/(\d)+|  # is this valid?

I assume the regex will match any article (without the slashes, since to PHP programmers it will be natural to assume the slashes are necessary for the regex.

workbox.routing.registerRoute(
  new RegExp('{^/products|categories/}')

At the end of my journey down regex lane, here's my trip report:

  • the code currently generates new RegExp('$regexString'), which isn't intuitive to PHP programmers and excludes the ability to use flags.
  • Instead, I think it should generate the regex string itself, which is javascript, e.g. workbox.routing.registerRoute(/products|categories/, ...
  • We could have another matcher, RegExp: that generates what the code currently does, and regex: that generates a javascript regex.

Regardless, the docs should be updated. I'll move my suggestion to an issue in the bundle repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.