google-app-enginegoogle-cloud-platformregex-lookaroundsapp.yaml

Support for negative lookbehind regex in app.yaml


I am trying to exclude all source map files, i.e files ending with .map from being uploaded to app engine. Here's a snippet of the config in app.yaml file.

handlers:
- url: /(.*\\..+(?\<!map))$
  static_files: \\1
  upload: /(.*\\..+(?\<!map))$
  secure: always

However, when deploying, this is the error that I get.

content <{
  "error": {
    "code": 400,
    "message": "The request is invalid.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "version.handlers[0].url_regex",
            "description": "Value \"/(.*\\..+(?\\\u003c!map))$\" must be a valid regular expression. Details: invalid or unsupported Perl syntax."
          },
          {
            "field": "version.handlers[0].static_files.upload_path_regex",
            "description": "Value \"/(.*\\..+(?\\\u003c!map))$\" must be a valid regular expression. Details: invalid or unsupported Perl syntax."
          }
        ]
      }

In the app.yaml reference documentation, it implies that it supports POSIX extended regular expression syntax.

Might anyone advice on what should be done to fix this.


Solution

  • You can use

    ^(.*([^.].{3}|.[^m].{2}|.{2}[^a].|.{3}[^p])|.{0,3})$
    

    See the regex demo. Details: