Skip to content
Permalink
Browse files

Update grunt and travis

Fix ignoreSubdomain functionality
Return the hostname and the tld if ignoreSubdomain is check.
The regex will catch the hostname and tld, all subdomain will be ignored. By @florianaudon
  • Loading branch information...
brantje committed May 13, 2017
1 parent d293f83 commit 8dbc5eac6fde05d31b96d87ab884502855402e4c
Showing with 60 additions and 66 deletions.
  1. +4 −1 .travis.yml
  2. +1 −1 Gruntfile.js
  3. +4 −9 js/lib/parseUrl.js
  4. +51 −55 tests/unit/lib/parseUrl.js
@@ -5,4 +5,7 @@ before_install:
before_script:
- npm install
script:
- grunt hint
- grunt test

addons:
firefox: "latest"
@@ -106,7 +106,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-karma');
// Default task(s).

grunt.registerTask('hint', ['jshint']);
grunt.registerTask('test', ['karma', 'jshint']);
grunt.registerTask('build', ['execute:fixLocale','jshint', 'clean:dist', 'mkdir:dist', 'copy:dist', 'compress:dist']);
grunt.registerTask('dist', ['']);

@@ -49,13 +49,8 @@ function processURL(URL, ignoreProtocol, ignoreSubdomain, ignorePath, ignorePort
baseHost = host;
}
else {
var result = host.match(/[^./]+\.[^./]+$/);
var TLDlength = 0;
if(result){
TLDlength = result[0].length;
}

baseHost = splittedURL.slice(-TLDlength - 1).join(".");
var result = host.match(/[^./]+\.[^./]+$/); // catch the two last parts, it's de hostname and the tld
baseHost=result[0];
}
var returnURL = "";
if (!ignoreProtocol) {
@@ -65,7 +60,7 @@ function processURL(URL, ignoreProtocol, ignoreSubdomain, ignorePath, ignorePort
returnURL += host;
}
else {
returnURL += host;
returnURL += baseHost;//return the hostname and the tld of the website if ignoreSubdomain is check
}
if (ignorePort) {
returnURL = returnURL.replace(':' + port, "");
@@ -77,4 +72,4 @@ function processURL(URL, ignoreProtocol, ignoreSubdomain, ignorePath, ignorePort
returnURL = returnURL.slice(0, -1);
}
return returnURL;
}
}

0 comments on commit 8dbc5ea

Please sign in to comment.
You can’t perform that action at this time.