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

fix: encode link url unnecessarily #1641

Merged
merged 5 commits into from
Jul 6, 2021
Merged

fix: encode link url unnecessarily #1641

merged 5 commits into from
Jul 6, 2021

Conversation

js87zz
Copy link
Contributor

@js87zz js87zz commented Jul 6, 2021

Please check if the PR fulfills these requirements

  • It's the right issue type on the title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has a description of the breaking change

Description


Thank you for your contribution to TOAST UI product. 🎉 😘 ✨

Copy link
Contributor

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰완료합니다.

Copy link
Contributor

@jwlee1108 jwlee1108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료합니다.

Copy link

@adhrinae adhrinae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료합니다

Comment on lines 1 to 3
const encodingRegExps = [/\(/g, /\)/g, /\[/g, /\]/g, /</g, />/g, / /g];
const encodedList = ['%28', '%29', '%5B', '%5D', '%3C', '%3E', '%20'];
const escapedList = ['\\(', '\\)', '\\[', '\\]', '\\<', '\\>', ' '];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

배열들이 나란히 있어서 눈에 들어오긴 하는데, 각각의 encodingRegExp, encoded, escaped 가 한묶음씩 보인다면 가독성이 나아질지도 모르겠네요. 드물겠지만 새로운 변환 규칙 추가할 때 하나라도 빼먹는 것을 방지할 수 있겠고요. 막상 예제를 만들어보니까 코드 양이 좀 불필요하게 늘어나는 것 같긴 하지만요.

const encoderList = [
  {
    target: /\(/g,
    result: { encoded: '%28', escaped: '\\(' }
  },
  // ... 
];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

더 복잡해지는 것 같아서 아래처럼 맵을 사용하되 좀 더 축약했습니다~

const encoderList = [
  {
    regExp: /\(/g,
    encoded: '%28',
    escaped: '\\(',
  },
  {
    regExp: /\)/g,
    encoded: '%29',
    escaped: '\\)',
  },
  {
    regExp: /\[/g,
    encoded: '%5B',
    escaped: '\\[',
  },
  {
    regExp: /\]/g,
    encoded: '%5D',
    escaped: '\\]',
  },
  {
    regExp: /</g,
    encoded: '%3C',
    escaped: '\\<',
  },
  {
    regExp: />/g,
    encoded: '%3E',
    escaped: '\\>',
  },
  {
    regExp: / /g,
    encoded: '%20',
    escaped: ' ',
  },
];

@js87zz js87zz force-pushed the fix/encode-link-url branch from 3d7e36c to d5d6c56 Compare July 6, 2021 07:27
@js87zz js87zz merged commit 03b7b19 into master Jul 6, 2021
@js87zz js87zz deleted the fix/encode-link-url branch July 6, 2021 07:27
Copy link

@dongsik-yoo dongsik-yoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료합니다. 수고하셨어요.

ahamelers pushed a commit to ahamelers/tui.editor that referenced this pull request Aug 21, 2023
* fix: decode url when executing addImage, addLink command

* chore: add test case(addImage, addLink)

* chore: apply code review

* refactor: assertToContainHTML function

* chore: add test case(converting the html block which has "=" attr value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants