Last active
September 14, 2023 15:27
-
-
Save siebird/3c313d12a0e2601f114f84386cec60db to your computer and use it in GitHub Desktop.
Bookmarklet to convert current url to a DDEV url
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
/* | |
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; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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