Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectorUtils.matchPath(): inconsistent behaviour on POSIX-like and Windows for single Wildcard pattern #191

Closed
fishermans opened this issue Mar 30, 2022 · 0 comments

Comments

@fishermans
Copy link
Contributor

Hi,

I was wondering why maven-shade-plugin produces different results on Windows and MAC. The single wildcard match is working inconsistently depending on the OS.

Please find a test to reproduce this (see comments in test file):

import org.codehaus.plexus.util.SelectorUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class PatternMatcherTest {

  @Test
  void testPatternMatchSingleWildCardLinux() {

    /* Passes on Linux - fails on Windows */
    Assertions.assertFalse(SelectorUtils.matchPath(
            "/com/test/*",
            "/com/test/test/hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardCaseInLinux() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "/com/test/**",
            "/com/test/test/hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardLinux() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "/com/test/**",
            "/com/test/test/hallo"));
  }


  @Test
  void testPatternMatchSingleWildCardWindows() {

    /* Fails on Linux - passes on Windows */
    Assertions.assertFalse(SelectorUtils.matchPath(
            "D:\\com\\test\\*",
            "D:\\com\\test\\test\\hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardWindows() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "D:\\com\\test\\**",
            "D:\\com\\test\\test\\hallo"));
  }


  @Test
  void testPatternMatchSingleWildCardDotLinux() {

    /* Fails on Linux - fails on Windows */
    Assertions.assertFalse(SelectorUtils.matchPath(
            "com.test.*",
            "com.test.test.hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardDotLinux() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "com.test.**",
            "com.test.test.hallo"));
  }
}

BG

fishermans added a commit to fishermans/plexus-utils that referenced this issue Mar 30, 2022
@fishermans fishermans mentioned this issue Mar 30, 2022
@michael-o michael-o changed the title SekectorUtils.matchPath(..) - inconsistent behaviour on Linux and Windows for single Wildcard pattern SelectorUtils.matchPath(..) - inconsistent behaviour on Linux and Windows for single Wildcard pattern Apr 17, 2022
fishermans added a commit to fishermans/plexus-utils that referenced this issue Apr 26, 2022
michael-o pushed a commit that referenced this issue May 17, 2022
@michael-o michael-o changed the title SelectorUtils.matchPath(..) - inconsistent behaviour on Linux and Windows for single Wildcard pattern SelectorUtils.matchPath(): inconsistent behaviour on POSIX-like and Windows for single Wildcard pattern May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant