docstr: Properly check whether a URL can be served from the static folder.
code: def test_path_traversal(self):
      """Properly check whether a URL can be served from the static folder."""
      with mock.patch(
          "builtins.open", mock.mock_open(read_data="data")
      ):
          self.assertTrue(is_path_safe("static/index.js"))
          self.assertTrue(is_path_safe("./static/index.js"))
          self.assertTrue(is_path_safe("static/../static/index.js"))
  
          self.assertFalse(is_path_safe("../static/index.js"))
          self.assertFalse(is_path_safe("../index.js"))
          self.assertFalse(is_path_safe("static2/index.js"))
          self.assertFalse(is_path_safe("notstatic/index.js"))
          self.assertFalse(is_path_safe("static/../../index.js"))
          self.assertFalse(is_path_safe("..%2findex.js"))
          self.assertFalse(is_path_safe("%2e%2e/index.js"))
          self.assertFalse(is_path_safe("%2e%2e%2findex.js"))
          self.assertFalse(
              is_path_safe(
                  "static/../..\\org_tensorflow_tensorboard\\static\\index.js"
              )
          )
          self.assertFalse(
              is_path_safe(
                  "static/../../org_tensorflow_tensorboard/static/index.js"
              )
          )
          self.assertFalse(
              is_path_safe(
                  "static/%2e%2e%2f%2e%2e%5corg_tensorflow_tensorboard%5cstatic%5cindex.js"
              )
          )
          self.assertFalse(
              is_path_safe(
                  "static/%2e%2e%2f%2e%2e%2forg_tensorflow_tensorboard%2fstatic%2findex.js"
              )
          )
  
          # Test with OS specific path modules.
          with mock.patch("os.path", posixpath):
              self.assertTrue(is_path_safe("static/\\index.js"))
  
          with mock.patch("os.path", ntpath):
              self.assertFalse(is_path_safe("static/\\index.js"))
  
file_path: tensorboard/tensorboard/examples/plugins/example_raw_scalars/test.py
imports: import ntpath
  import posixpath
  import unittest
  from unittest import mock
  from werkzeug import test
  from werkzeug import wrappers
  from tensorboard.plugins import base_plugin
  from tensorboard.examples.plugins.example_raw_scalars.tensorboard_plugin_example_raw_scalars import plugin
label_desc: Use image node_id 1 for calling the UrlSafetyTest obj's underlying member method code with example usage: obj.test_path_traversal() without return types