pulsar-edit / package-backend

Pulsar Server Backend for Packages
https://api.pulsar-edit.dev
MIT License
12 stars 11 forks source link

Fix Query Parameter `rename` #112

Closed confused-Techie closed 1 year ago

confused-Techie commented 1 year ago

Requirements

Description of the Change

When publishing a new package version there is an optional query parameter of rename that can be accepted.

During original research into the backend the belief was this was a string based boolean such as rename=true or rename=false.

But seeing as how the --rename flag of PPM functions, it seems that this command will actually modify the package.json with the text used after the CLI flag. And append it as a query parameter with the same value.

Such as using pulsar -p publish --rename titanium will translate to ?rename=titanium.

So this PR changes how the rename query parameter is parsed.

Since the backend still is able to resolve the new name of a package by finding the name listed in the package.json of the remote package, we can keep the changes minimal for now. Instead parsing this properly to accept any string based value with a length more than 0 as setting rename true.

So technically using rename=a will successfully cause the backend to rename a package to whatever is listed in the package.json. Of course this shouldn't be recommended as the goal would be to fix this in future updates to the package-backend. But this does allow this flag to function as expected for now.

Resolves #108