Skip to content

Instantly share code, notes, and snippets.

@siebird
Last active September 14, 2023 15:27
Show Gist options
  • Save siebird/3c313d12a0e2601f114f84386cec60db to your computer and use it in GitHub Desktop.
Save siebird/3c313d12a0e2601f114f84386cec60db to your computer and use it in GitHub Desktop.
Bookmarklet to convert current url to a DDEV url
/*
A bookmarket to convert a live URL to a DDEV URL. To install bookmarklet:
- right click in bookmark bar or go to bookmark manager to add new page in your browser
- click `add page`
- name 'DDEV URL` or whatever you want
- copy and paste the code below into the URL field. Lines 9-16.
*/
javascript:(function(){
const url = window.location.href;
const tld = url.split('/')[2];
const domain = tld.split('.').slice(0);
const ddev = domain[domain.length - 2] + '.ddev.site';
const ddevUrl = url.replace(tld, ddev);
window.location.href = ddevUrl;
})();
@siebird
Copy link
Author

siebird commented Aug 8, 2023

This bookmarklet assumes that your DDEV project naming convention mirrors the projects primary domain: example.com|www.example.com|staging.example.com => example.ddev.site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment