laixintao / laixintao/problems

shorten url

Open
#31 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

一个短连接服务,可以把 https://channel-m.jd.com/pc/psp/100002533712?imup=Cg8KCWpkbGFpYm9zcxIAGAASHAjQovbE9AIQy67w3AMaCGh6c2pkemprIPBgKAEYsRsgACoUaWUsdWIseGdhLGdhLGNpYSxiYWIyAmllOi0KC3NoYW5namluZ2pkENSUHxgDIOGC5vHQ6qWSdSja2pA4MNnakDg4E0CAgCA&extension_id=eyJhZCI6IiIsImNoIjoiIiwic2hvcCI6IiIsInNrdSI6IiIsInRzIjoiIiwidW5pcWlkIjoie1wiY2xpY2tfaWRcIjpcIjgyZmEyMDRlLTkyY2EtNDViMS04MjFmLTQ5NDI3ZmQwMjQyY1wiLFwibWF0ZXJpYWxfaWRcIjpcIjg0NDEwMzc5OTMxNjU4MTYxNjFcIixcInBvc19pZFwiOlwiMzUwNVwiLFwic2lkXCI6XCI3ZDQ0MGM0MS1hYmRiLTQ3NTAtYjU3Yi0wMTE3NWRmYjg5YWNcIn0ifQ==&jd_pop=82fa204e-92ca-45b1-821f-49427fd0242c&abt=0 这个链接,变成 https://channel-m.jd.com/pc/psp/100002533712,效果是完全相等的。

实现:

  • 每次用户输入的时候,尝试采用“策略”去掉一些参数,比如内置的策略遍历删除一个 query params,或者先尝试删除 spm 参数(阿里系惯用的这样埋点),然后再尝试遍历删除;
  • 删除一个参数的时候,尝试去访问这个url,估计要开无头浏览器,然后对比两张网页的图片相似度,如果相似,就说明这个参数是可以删除的,继续基于这个参数删除;

优化:

  • 如果成功删除了参数,那么就根据缩短之后的url和之前的进行对比,能否找出两者之间共同的 regex,如果能的话,就添加策略,最高优先级:即 [能否match regex,如果能,就使用这个策略,对比前后是否相同,如果不能,就采用 spm删除策略,如果还不能,就尝试随机删除url], 策略之间可能依然需要在进程内缓存下来已经尝试过的url;
  • 所有被成功缩短过的 pair ,可能都需要缓存下来,用来推导出来这个规则

界面:

  • 只有一个 input 输入框;
image
  • 通过 asyncio + websocket 实时展示状态

API:

  • 同步阻塞 API;
  • 需要添加缓存!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no existing files or tests. Start by reviewing the proposed URL-shortening workflow, the single-input interface, and the asyncio/WebSocket status flow; done would require an agreed implementation scope covering the synchronous API and caching.

Written by the indexing model from the issue text.

Assessment

Domain
backend-api-design, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.