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

fix: swap_vanity_urls() works predictably with unset vanity URLs [DRAFT] #361

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

toph-allen
Copy link
Collaborator

Intent

When swap_vanity_url() was called on a piece of content without a vanity URL, the URL would be replaced with a randomized placeholder URL during the swap.

Fixes #360

Approach

Instead of using a placeholder URL, delete the vanity URLs and re-assign them if vanity URLs are non-null.

Perhaps a better approach would be to call set_vanity_url(content, url, force = TRUE), as this doesn't risk the (admittedly very unlikely) case that another piece of content snipes the URL before it's reassigned.

I also renamed the function and its arguments, retaining the old name as a deprecated function that calls the new function for back compat. The old function was named swap_vanity_url(from, to). This did not make clear that the operation is symmetrical and operates on two pieces of content, one or both of which can have vanity URLs that are swapped. The new function is called swap_vanity_urls(content_a, content_b).

Note

This is marked as a draft for now. I want to add proper error handling, so that in the case of a permissions error we correctly restore any changes that had been made.

Checklist

  • Does this change update NEWS.md (referencing the connected issue if necessary)? NOT YET
  • Does this change need documentation? Have you run devtools::document()?

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

Successfully merging this pull request may close these issues.

swap_vanity_url(content1, content2) assigns junk URLs if one content item has no vanity set
1 participant