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

Url should ignore the fullwidth code #378

Closed
crossle opened this issue Apr 23, 2019 · 3 comments
Closed

Url should ignore the fullwidth code #378

crossle opened this issue Apr 23, 2019 · 3 comments

Comments

@crossle
Copy link

crossle commented Apr 23, 2019

fullwith symbol should be ingore, like https://google.com,你好
https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms

@rodneyrehm
Copy link
Member

Where should that symbol be ignored specifically?

@crossle
Copy link
Author

crossle commented Apr 23, 2019

like (https://www.googoe.com/CN_UST);it's use fullwidth symbol and

@rodneyrehm
Copy link
Member

rodneyrehm commented Apr 23, 2019

To make sure i understood correctly: you'd like URI.withinString() to categorically exclude fullwidth characters (U+FF00 - U+FFEF) from URLs.

This could be achieved by extending URI.findUri.end:

URI.findUri.end = /[\s\r\n]|[\uFF00-\uFFEF]|$/;

var text = "like (https://www.googoe.com/CN_UST);it's use fullwidth symbol `( `and` )`"
  + "\n"
  + "fullwith symbol should be ingore, like https://google.com,你好 "
  + "https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms";

var result = URI.withinString(text, url => {
  console.log('found:', url);
  return '<a>' + url + '</a>';
});

console.log('replaced:', result);

which would output:

found: https://www.googoe.com/CN_UST
found: https://google.com
found: https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms
replaced: like (<a>https://www.googoe.com/CN_UST</a>);it's use fullwidth symbol `( `and` )`
fullwith symbol should be ingore, like <a>https://google.com</a>,你好 <a>https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms</a>

It should be noted that neither github's URL matcher, nor Chrome Dev Tools' URL matcher behaves that way. Both include fullwidth characters. Also, URL accepts fullwidth characters:

var url = new URL("https://www.googoe.com/CN_UST);it's");
console.log(url.href);
// https://www.googoe.com/CN_UST%EF%BC%89%EF%BC%9Bit's

@crossle crossle closed this as completed Apr 23, 2019
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

No branches or pull requests

2 participants