Changes between Version 4 and Version 8 of Ticket #7296


Ignore:
Timestamp:
02/21/2019 11:31:05 AM (6 months ago)
Author:
mjethani
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7296

    • Property Cc greiner added
    • Property Summary changed from Implement hostname extraction using a regular expression to Implement lightweight URL parsing
  • Ticket #7296 – Description

    v4 v8  
    11=== Background === 
    2 In the extension we use the [https://developer.mozilla.org/en-US/docs/Web/API/URL URL] object just to extract the hostname from a URL. This is not very efficient as it must parse the entire URL. Extraction of the hostname can be implemented using a regular expression instead: 
     2In the extension we use the [https://developer.mozilla.org/en-US/docs/Web/API/URL URL] object just to extract the protocol and the hostname from a URL. This is not very efficient as it must parse the entire URL. Extraction of the protocol and the hostname can be implemented using a regular expression instead: 
    33 
    44{{{ 
    5 let [, hostname] = /^(?:[^:]+:)(?:\/\/(?:[^\/]*@)?(\[[^\]]*\]|[^:\/]+))?/ 
    6                    .exec(url) || []; 
     5let [, protocol, hostname] = /^([^:]+:)(?:\/\/(?:[^/]*@)?(\[[^\]]*\]|[^:/]+))?/ 
     6                             .exec(url) || []; 
    77}}} 
    88