-
Notifications
You must be signed in to change notification settings - Fork 313
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
fix(pub): Improve support for custom package repositories #8876
base: main
Are you sure you want to change the base?
Conversation
plugins/package-managers/pub/src/test/kotlin/utils/PubCacheReaderTest.kt
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8876 +/- ##
=========================================
Coverage 67.54% 67.54%
- Complexity 1166 1167 +1
=========================================
Files 244 244
Lines 7775 7775
Branches 865 865
=========================================
Hits 5252 5252
Misses 2167 2167
Partials 356 356
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
plugins/package-managers/pub/src/main/kotlin/utils/PubCacheReader.kt
Outdated
Show resolved
Hide resolved
plugins/package-managers/pub/src/test/kotlin/utils/PubCacheReaderTest.kt
Outdated
Show resolved
Hide resolved
plugins/package-managers/pub/src/test/kotlin/utils/PubCacheReaderTest.kt
Show resolved
Hide resolved
Signed-off-by: Timo Salmi <Syyllinen@users.noreply.github.com>
162853f
to
02892eb
Compare
@@ -85,13 +85,13 @@ internal class PubCacheReader(flutterHome: File? = null) { | |||
val path = if (type == "hosted" && url.isNotEmpty()) { | |||
// Packages with source set to "hosted" and "url" key in description set to "https://pub.dartlang.org". | |||
// The path should be resolved to "hosted/pub.dartlang.org/packageName-packageVersion". | |||
"hosted/${url.replace("https://", "")}/$packageName-$packageVersion" | |||
"hosted/${url.replace("https://", "").replace("/", "%47")}/$packageName-$packageVersion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "/" really the only character that needs to be escaped here? If there's a chance that other characters might need to be escaped as well, should we use our String.fileSystemEncode()
function instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see... https://github.com/dart-lang/pub/blob/ea4a1c854690d3abceb92c8cc2c6454470f9d5a7/doc/cache_layout.md?plain=1#L72 says
The url of the repository is encoded to a directory name with a weird URI-like
encoding. This is a mistake that seems costly to fix, but is worth being aware
of.
And the code in https://github.com/dart-lang/pub/blob/ea4a1c854690d3abceb92c8cc2c6454470f9d5a7/lib/src/source/hosted.dart#L1911
return replace(
url,
RegExp(r'[<>:"\\/|?*%]'),
(match) => '%${match[0]!.codeUnitAt(0)}',
);
String.fileSystemEncode()
does not work because Pub uses decimal value instead of hex value.
But now that I found the original code, I will add replace function for the missing 9 chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pub uses decimal value instead of hex value.
Wow, that's indeed weird!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now that I found the original code, I will add replace function for the missing 9 chars.
Any update here, @Syyllinen?
I came across with some corner cases when teams are using custom package repositories in their
pubspec.yaml
These packages will end up in
.pub-cache
directory