- Use
regexp
package and create the global variablevalidPath
to store our validation expression. - Add the function
getTitle
that uses thevalidPath
expression to validate path and extract the page title. - Put a call to
getTitle
in each of the handlers.