-
-
Save anonymous/6b3af8384efb3a7fc1a6e9205dfbf460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Home.pm b/lib/Mojo/Home.pm | |
index c5cf0fbe1..e46c49c8f 100644 | |
--- a/lib/Mojo/Home.pm | |
+++ b/lib/Mojo/Home.pm | |
@@ -12,9 +12,10 @@ sub detect { | |
# Location of the application class (Windows mixes backslash and slash) | |
elsif ($class && (my $path = $INC{my $file = class_to_path $class})) { | |
- $path =~ s!\\!/!g; | |
- $path =~ s!(?:(?:^|/)b?lib)?/\Q$file\E$!!; | |
- $detected = Mojo::File->new($path)->to_abs; | |
+ my $parts = Mojo::File->new($path)->to_array; | |
+ pop @$parts for 1 .. @{Mojo::File->new($file)}; | |
+ pop @$parts if @$parts && ($parts->[-1] eq 'blib' || $parts->[-1] eq 'lib'); | |
+ $detected = Mojo::File->new(@$parts)->to_abs; | |
} | |
$$self = $detected->to_string if $detected; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment