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

Add provider function for IDN #21

Closed
jkroepke opened this issue May 25, 2024 · 1 comment · Fixed by #26
Closed

Add provider function for IDN #21

jkroepke opened this issue May 25, 2024 · 1 comment · Fixed by #26
Labels
Kind/Feature New functionallity/feature

Comments

@jkroepke
Copy link
Member

Ref: timohirt/terraform-provider-hetznerdns#28

We should add an provider function to convert domains into punycode (IDN).

Provider functions are part of the framework (https://developer.hashicorp.com/terraform/plugin/framework/functions) and require terraform 1.8

@kimdre kimdre added the Kind/Feature New functionallity/feature label May 25, 2024
@kimdre
Copy link
Member

kimdre commented May 26, 2024

A simple example for this would be

package main

import (
	"fmt"

	"golang.org/x/net/idna"
)

var p *idna.Profile

func main() {
	p = idna.New()

	var url = "🍻über🔥.com"

	ascii, err := p.ToASCII(url)

	if err != nil {
		fmt.Println(err)
		return
	}

	unicode, err := p.ToUnicode(ascii)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(ascii)
	fmt.Println(unicode)
}

which will output

xn--ber-goa88194dfdc.com
🍻über🔥.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind/Feature New functionallity/feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants