mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 07:21:43 +00:00
Update the Punycode Public API client
This commit is contained in:
parent
f2044bcfbf
commit
b1428867dc
|
@ -1,15 +0,0 @@
|
||||||
#-*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def main(args):
|
|
||||||
if len(args) < 2:
|
|
||||||
print("Insufficient arguments")
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
encoded_domain = args[1].encode('idna').decode("utf-8")
|
|
||||||
|
|
||||||
print(encoded_domain)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv)
|
|
|
@ -1,11 +1,39 @@
|
||||||
var Py3 = require("lib/python3");
|
// punycode.js
|
||||||
|
// Namhyeon Go <abuse@catswords.net>
|
||||||
|
// https://github.com/gnh1201/welsonjs
|
||||||
|
//
|
||||||
|
// ***SECURITY NOTICE***
|
||||||
|
// The Punycode (IDN) library requires an internet connection. Data may be transmitted externally. Users must also comply with the terms of use.
|
||||||
|
// - Privacy Policy: https://policy.catswords.social/site_terms.html
|
||||||
|
// - Terms of Service: https://policy.catswords.social/site_extended_description.html
|
||||||
|
//
|
||||||
|
var JsonRpc2 = require("lib/jsonrpc2");
|
||||||
|
|
||||||
|
var API_URL = "https://public-api.catswords.net";
|
||||||
|
|
||||||
function encode(s) {
|
function encode(s) {
|
||||||
return Py3.execScript("app\\assets\\py\\idnaencode.py", [s]).trim();
|
var rpc = JsonRpc2.create(API_URL);
|
||||||
|
var result = rpc.invoke("relay_invoke_method", {
|
||||||
|
"callback": "idn_to_ascii",
|
||||||
|
"args": [s]
|
||||||
|
}, "");
|
||||||
|
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function decode(s) {
|
||||||
|
var rpc = JsonRpc2.create(API_URL);
|
||||||
|
var result = rpc.invoke("relay_invoke_method", {
|
||||||
|
"callback": "idn_to_utf8",
|
||||||
|
"args": [s]
|
||||||
|
}, "");
|
||||||
|
|
||||||
|
return result.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.encode = encode;
|
exports.encode = encode;
|
||||||
|
exports.decode = decode;
|
||||||
|
|
||||||
exports.VERSIONINFO = "Punycode Converter (punycode.js) version 0.1";
|
exports.VERSIONINFO = "Punycode Public API client (punycode.js) version 0.2";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user