Update `resource_strip_prefix` logic to support path handling across modules (#1389)

* Add nested module resources example and update resource_strip_prefix handling

- Add an example with a nested module structure
- Update `resource_strip_prefix` logic to support path handling across modules

* Fix

* Write unit tests

* Fix test
diff --git a/examples/nested_module_resources/BUILD.bazel b/examples/nested_module_resources/BUILD.bazel
new file mode 100644
index 0000000..bc93da9
--- /dev/null
+++ b/examples/nested_module_resources/BUILD.bazel
@@ -0,0 +1,8 @@
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary")
+
+kt_jvm_binary(
+    name = "main",
+    srcs = glob(["*.kt"]),
+    main_class = "MainKt",
+    deps = ["@nested//:printer"],
+)
diff --git a/examples/nested_module_resources/MODULE.bazel b/examples/nested_module_resources/MODULE.bazel
new file mode 100644
index 0000000..86e6389
--- /dev/null
+++ b/examples/nested_module_resources/MODULE.bazel
@@ -0,0 +1,13 @@
+module(name = "nested_module_resources")
+
+bazel_dep(name = "rules_kotlin", version = "1.9.5")
+local_path_override(
+    module_name = "rules_kotlin",
+    path = "../..",
+)
+
+bazel_dep(name = "nested", version = "0")
+local_path_override(
+    module_name = "nested",
+    path = "nested",
+)
diff --git a/examples/nested_module_resources/Main.kt b/examples/nested_module_resources/Main.kt
new file mode 100644
index 0000000..384ac11
--- /dev/null
+++ b/examples/nested_module_resources/Main.kt
@@ -0,0 +1,3 @@
+fun main() {
+    printMessage()
+}
diff --git a/examples/nested_module_resources/README.md b/examples/nested_module_resources/README.md
new file mode 100644
index 0000000..e5e090b
--- /dev/null
+++ b/examples/nested_module_resources/README.md
@@ -0,0 +1,47 @@
+# Nested Module Resources Example
+
+## What This Tests
+
+This example tests **resource path resolution across Bazel module boundaries** when using `resource_strip_prefix`.
+
+## Problem Statement
+
+When a target in one Bazel module depends on a library in an external Bazel module that has resources with a custom `resource_strip_prefix`, the resource paths need to be correctly resolved.
+
+### Module Structure
+
+```
+nested_module_resources/          # Main module
+├── MODULE.bazel                   # bazel_dep(name = "nested")
+├── Main.kt                        # Calls @nested//:printer
+└── nested/                        # SEPARATE BAZEL MODULE
+    ├── MODULE.bazel               # module(name = "nested")
+    ├── Printer.kt
+    ├── BUILD.bazel                # resource_strip_prefix = "resourcez"
+    └── resourcez/
+        └── resource.txt
+```
+
+**Key Point:** `nested/` is a separate Bazel module with its own `MODULE.bazel`, not just a subdirectory.
+
+## The Bug (Before Fix)
+
+Without the fix in PR #1390, resource paths from external modules included the module path prefix, causing the strip prefix check to fail:
+
+### With nested/ in .bazelignore:
+```
+Error in fail: Resource file ../nested+/resourcez/resource.txt is not under
+the specified prefix to strip resourcez
+```
+- Resource path: `../nested+/resourcez/resource.txt`
+- Strip prefix: `resourcez`
+- Check fails: `../nested+/resourcez/resource.txt` doesn't start with `resourcez`
+
+### Without .bazelignore:
+```
+Error in fail: Resource file nested/resourcez/resource.txt is not under
+the specified prefix to strip resourcez
+```
+- Resource path: `nested/resourcez/resource.txt`
+- Strip prefix: `resourcez`
+- Check fails: `nested/resourcez/resource.txt` doesn't start with `resourcez`
diff --git a/examples/nested_module_resources/nested/BUILD.bazel b/examples/nested_module_resources/nested/BUILD.bazel
new file mode 100644
index 0000000..322df55
--- /dev/null
+++ b/examples/nested_module_resources/nested/BUILD.bazel
@@ -0,0 +1,9 @@
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
+
+kt_jvm_library(
+    name = "printer",
+    srcs = glob(["*.kt"]),
+    resource_strip_prefix = "resourcez",
+    resources = glob(["resourcez/**"]),
+    visibility = ["//visibility:public"],
+)
diff --git a/examples/nested_module_resources/nested/MODULE.bazel b/examples/nested_module_resources/nested/MODULE.bazel
new file mode 100644
index 0000000..29489fc
--- /dev/null
+++ b/examples/nested_module_resources/nested/MODULE.bazel
@@ -0,0 +1,7 @@
+module(name = "nested")
+
+bazel_dep(name = "rules_kotlin", version = "1.9.5")
+local_path_override(
+    module_name = "rules_kotlin",
+    path = "../../..",
+)
diff --git a/examples/nested_module_resources/nested/Printer.kt b/examples/nested_module_resources/nested/Printer.kt
new file mode 100644
index 0000000..086dbcf
--- /dev/null
+++ b/examples/nested_module_resources/nested/Printer.kt
@@ -0,0 +1,8 @@
+fun printMessage() {
+  val resourceName = "resource.txt"
+  val resourceUrl = Thread.currentThread().contextClassLoader.getResource(resourceName)
+  val resourceText = resourceUrl?.readText()
+
+  println("Hello $resourceText")
+}
+
diff --git a/examples/nested_module_resources/nested/resourcez/resource.txt b/examples/nested_module_resources/nested/resourcez/resource.txt
new file mode 100644
index 0000000..04fea06
--- /dev/null
+++ b/examples/nested_module_resources/nested/resourcez/resource.txt
@@ -0,0 +1 @@
+world
\ No newline at end of file