From the course: JavaScript: Service Workers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Work with dynamic routes

Work with dynamic routes - JavaScript Tutorial

From the course: JavaScript: Service Workers

Start my 1-month free trial

Work with dynamic routes

- [Instructor] And we are back with the code. In this case, we are going to work with dynamic routes. So in the last video, we had been working with exact match. So we were looking for exactly one particular URL. But sometimes, it's more difficult because we want to work directly with a folder or with one kind of file, for example JPEG files. So let's say for example that we will have an API. And that API will be available under /api. So let's say that we want to do something different for that particular thing. And of course under API I can have several things. For example, api/weather. I can have api/currency. So different APIs, but they are all under the API sub folder. For that we can use regular expressions. So, we can do something like that. We can take that parsed URL. We are still going to work with the path name, and we're going to check if it's going to match a regular expression. So matches a function, this is a string function that will receive a regular expression. And…

Contents