[PR #411] [MERGED] Improved relative path checking based on file existence #901

Closed
opened 2025-12-29 08:33:57 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/411
Author: @NoahLerner
Created: 1/30/2020
Status: Merged
Merged: 2/2/2020
Merged by: @StefH

Base: masterHead: Improved_RelativePath_BodyAsFile


📝 Commits (10+)

  • c1f757b Improved relative path checking based on file existence
  • 962824f Apply File.Exists logic to ReadResponseBodyAsString as well
  • 9bc737f Make path handling more robust since path is user defined
  • e8a8314 Unit tests for relative path feature
  • 66448a9 Replace all back and forward slashes with system dependent DirectorySeparatorChar
  • 3681e64 Attempt fix broken directory separator chars for Unix platforms
  • 88f48ac Revert wrapping GetMappingFolder with CleanPath
  • 11f36fc Move CleanPath logic to its own class
  • 3061226 Remove whitespace
  • 01b9c5d Remove more whitespace

📊 Changes

6 files changed (+155 additions, -13 deletions)

View changed files

📝 src/WireMock.Net/Handlers/LocalFileSystemHandler.cs (+6 -5)
src/WireMock.Net/Util/PathUtils.cs (+36 -0)
📝 test/WireMock.Net.Tests/ResponseBuilders/ResponseWithBodyFromFileTests.cs (+63 -8)
test/WireMock.Net.Tests/Util/PathUtilsTests.cs (+44 -0)
📝 test/WireMock.Net.Tests/WireMock.Net.Tests.csproj (+3 -0)
test/WireMock.Net.Tests/__admin/mappings/subdirectory/MyXmlResponse.xml (+3 -0)

📄 Description

If the file exists at the relative path, then use it. If not, then use the path as is.

This is stronger than the previous check if the path is just the filename, since if it's just a file name then we'll check if the file exists at the relative path & then use if yes. Otherwise, use the path as is.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/wiremock/WireMock.Net/pull/411 **Author:** [@NoahLerner](https://github.com/NoahLerner) **Created:** 1/30/2020 **Status:** ✅ Merged **Merged:** 2/2/2020 **Merged by:** [@StefH](https://github.com/StefH) **Base:** `master` ← **Head:** `Improved_RelativePath_BodyAsFile` --- ### 📝 Commits (10+) - [`c1f757b`](https://github.com/wiremock/WireMock.Net/commit/c1f757b487003698367c1b296aa77a76882c9279) Improved relative path checking based on file existence - [`962824f`](https://github.com/wiremock/WireMock.Net/commit/962824f61edb18d0cdde813a7db0b160e81dc058) Apply File.Exists logic to ReadResponseBodyAsString as well - [`9bc737f`](https://github.com/wiremock/WireMock.Net/commit/9bc737f31c62154d4d6641b55d5540f4fe60543d) Make path handling more robust since path is user defined - [`e8a8314`](https://github.com/wiremock/WireMock.Net/commit/e8a83147953afdaba73c1bb5b3d8057595e4d10d) Unit tests for relative path feature - [`66448a9`](https://github.com/wiremock/WireMock.Net/commit/66448a9ea3202e32c033e884ac53445c6c66175d) Replace all back and forward slashes with system dependent DirectorySeparatorChar - [`3681e64`](https://github.com/wiremock/WireMock.Net/commit/3681e64680a2d3d433f734a560e4c2833969c610) Attempt fix broken directory separator chars for Unix platforms - [`88f48ac`](https://github.com/wiremock/WireMock.Net/commit/88f48acbb91bfba6b040332e59832940ff34f7cc) Revert wrapping GetMappingFolder with CleanPath - [`11f36fc`](https://github.com/wiremock/WireMock.Net/commit/11f36fc4bc115e3a9a2a261eb4853960565d203a) Move CleanPath logic to its own class - [`3061226`](https://github.com/wiremock/WireMock.Net/commit/306122609515aa53f84bf11229fb0523be7502ae) Remove whitespace - [`01b9c5d`](https://github.com/wiremock/WireMock.Net/commit/01b9c5ddfe1b6da47f7f992ebf87d58d7282f9dd) Remove more whitespace ### 📊 Changes **6 files changed** (+155 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/WireMock.Net/Handlers/LocalFileSystemHandler.cs` (+6 -5) ➕ `src/WireMock.Net/Util/PathUtils.cs` (+36 -0) 📝 `test/WireMock.Net.Tests/ResponseBuilders/ResponseWithBodyFromFileTests.cs` (+63 -8) ➕ `test/WireMock.Net.Tests/Util/PathUtilsTests.cs` (+44 -0) 📝 `test/WireMock.Net.Tests/WireMock.Net.Tests.csproj` (+3 -0) ➕ `test/WireMock.Net.Tests/__admin/mappings/subdirectory/MyXmlResponse.xml` (+3 -0) </details> ### 📄 Description If the file exists at the relative path, then use it. If not, then use the path as is. This is stronger than the previous check if the path is just the filename, since if it's just a file name then we'll check if the file exists at the relative path & then use if yes. Otherwise, use the path as is. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 08:33:57 +01:00
adam closed this issue 2025-12-29 08:33:57 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#901