Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions js/foundation.abide.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,15 @@ Abide.defaults = {
// From CommonRegexJS (@talyssonoc)
// https://github.com/talyssonoc/CommonRegexJS/blob/e2901b9f57222bc14069dc8f0598d5f412555411/lib/commonregex.js#L76
// For more restrictive URL Regexs, see https://mathiasbynens.be/demo/url-regex.
url: /^((?:(https?|ftps?|file|ssh|sftp):\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))$/,

url: (function() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): New use of const and template literals introduces ES2015 features into what appears to be an ES5-oriented file.

The new const, template literals, and IIFE-based RegExp mean this file now relies on ES2015 syntax. If this bundle must run in ES5-only environments (e.g., IE11 or non-transpiled tooling), this can cause syntax errors. If ES2015+ is required/guaranteed, no change needed; otherwise, please revert to ES5 constructs or ensure this file is transpiled.

const protocol = '(?:https?|ftps?|file|ssh|sftp):\\/\\/';
const www = 'www\\d{0,3}[.]';
const domain = '[a-z0-9.\\-]+[.][a-z]{2,4}\\/';
const body = '(?:[^\\s()<>]+|\\((?:[^\\s()<>]+|(?:\\([^\\s()<>]+\\)))*\\))+' +
'(?:\\((?:[^\\s()<>]+|(?:\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?\\xab\\xbb\\u201c\\u201d\\u2018\\u2019])';
return new RegExp(`^((?:${protocol}|${www}|${domain})${body})$`, 'i');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

question (bug_risk): The added i flag changes the URL validation semantics to be case-insensitive compared to the original regex.

The original regex was case-sensitive; constructing it with RegExp(..., 'i') makes the entire match case-insensitive (e.g., uppercase protocol/host now match). Please confirm this broader matching is expected by all callers, especially given the reference to the CommonRegexJS pattern. If not, remove the i flag to preserve the previous behavior.

})(),

// abc.de
domain : /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,

Expand Down