code-scan / cfwork_shortlink_text

使用cf的work实现的短网址和文本分享
Other
46 stars 19 forks source link

能否兼容Short Menu 的Responses #3

Closed coppea closed 2 years ago

coppea commented 2 years ago

cfwork_shortlink_text 的响应数据为 {"link":"https://abc.com","name":"dkfcd","type":"link"}

而Short Menu不支持name值,支持以下值

Responses The response received from your server must either be plain text, containg only the shortened URL, or JSON. The following JSON formats are supported by Short Menu:

{ "shorturl" : "SHORT_URL_HERE" } { "shortURL" : "SHORT_URL_HERE" } { "short" : "SHORT_URL_HERE" } { "id" : "SHORT_URL_HERE" } { "url_short" : "SHORT_URL_HERE" } { "data" : { "url" : "SHORT_URL_HERE" } } { "message" : "ERROR_MESSAGE_HERE" } Your API can also return an array whose first object is a dictionary conforming to one of the above formats.

https://shortmenu.com/support/custom-services/ 可否将name修改为short或者shorturl或者id,已支持Short Menu

code-scan commented 2 years ago

可以了,我给index.js增加了自定义key的常量,可以根据自己的需求修改

const admin_path = '/short_link_admin'
const api_path = '/short_api'
const url_key = 'link' // original url key
const url_name = 'name' // short code  key

改完之后request的key也会修改,需要注意下同步修改

coppea commented 2 years ago

又来打扰您了,short menu仅支持{ "shorturl" : "https://abc.com/123" },不支持{ "shorturl" : "123" } 即name返回值是“ https://abc.com/123 ”, 而不是 “ 123 ”

自己试了修改一直出错,不知怎么修改,大佬能否点拨一下

B站已三连 http://b23.tv/azzKhZQ

@code-scan