Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(grunt) {
},
clean: {
all: [
'build/temp/',
'build/temp/'
]
},
compress: {
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ From the Extensions Manager follow these steps:
* Navigate to the repo directory and select the "extension" directory
* Should be ~/Code/query-string-values-extension/extension

## Testing
Run tests with

grunt karma

## Using the extension

I haven't created a cool looking icon for this yet, but next to the navigation bar, you should see this icon ![Alt Query String Values] (https://raw.github.com/acolchado/query-string-values-extension/master/extension/img/icon-16.png), click it and you will see all of the query stirng values.
I haven't created a cool looking icon for this yet, but next to the navigation bar, you should see this icon ![Alt Query String Values] (https://raw.github.com/acolchado/query-string-values-extension/master/extension/img/icon-16.png), click it and you will see all of the query string values.

## Contributing

Expand Down
106 changes: 57 additions & 49 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
module.exports = function(config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath = '../';

// list of files / patterns to load in the browser
files = [
JASMINE,
JASMINE_ADAPTER,
'extension/js/queryStringParser.js',
'test/**/*.js'
];

// list of files to exclude
exclude = [
];

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari
// - PhantomJS
browsers = [
'PhantomJS'
];

// test results reporter to use
// possible values: dots || progress
reporter = ['progress', 'growl'];

// web server port
port = 9018;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
// base path, that will be used to resolve files and exclude
basePath: '../',

// list of files / patterns to load in the browser
files: [
'extension/js/queryStringParser.js',
'test/**/*.js'
],

// list of files to exclude
exclude: [
],

frameworks: ['jasmine'],

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari
// - PhantomJS
browsers: ['PhantomJS'],

// test results reporter to use
// possible values: dots || progress
reporters: ['spec', 'progress', 'growl'],

// web server port
port: 9018,

// cli runner port
runnerPort: 9100,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
//logLevel = config.LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,

plugins: [
'karma-phantomjs-launcher',
'karma-jasmine'
]

});
};
12 changes: 8 additions & 4 deletions extension/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ window.processTabUrl = function(tabUrl) {
var values = parser.getValues(query);
var itemsFound = false;

if(values!==null){
if(values.length){
var table = document.getElementById("query-values");
for(var name in values){


for(var i = 0, len = values.length; i< len; i++){
itemsFound = true;
var row = document.createElement("tr");
var colName = document.createElement("td");
var colValue = document.createElement("td");

colName.innerHTML = name;
colValue.innerHTML = values[name] || "&nbsp;";
for(var key in values[i]){
colName.innerHTML = key;
colValue.innerHTML = values[i][key] || "&nbsp;";
}

row.appendChild(colName);
row.appendChild(colValue);
Expand Down
7 changes: 4 additions & 3 deletions extension/js/queryStringParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ function QueryStringParser(){

this.getValues = function(url){
var query = this.getQueryFromUrl(url);
var values = {};
var values = [];
var match;
while (!!(match = this.regExQuerySearch.exec(query))){
values[this.decode(match[1])] = this.decode(match[2]);
var kv = {};
kv[this.decode(match[1])] = this.decode(match[2]);
values.push(kv);
}

return values;
};

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"grunt-contrib-concat": "latest",
"grunt-contrib-compress": "latest",
"grunt-karma": "latest",
"karma-jasmine": "latest",
"karma-phantomjs-launcher" : "latest",
"grunt-file-creator": "latest",
"jasmine-node": "latest",
"chai": "latest",
Expand Down
22 changes: 13 additions & 9 deletions test/queryStringParser-Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,43 @@ describe("queryStringParser", function() {

describe("getValues()", function(){
it("should parse one value", function() {
evaluateItem("http://github.com/?me=you", {me: "you"});
evaluateItem("http://github.com/?me=you", [{me: "you"}]);
});

it("should parse 2 values", function() {
evaluateItem("http://github.com/?me=you&yomama=andyourcousintoo", {me: "you", yomama: 'andyourcousintoo'});
evaluateItem("http://github.com/?me=you&yomama=andyourcousintoo", [{me: "you"}, {yomama: 'andyourcousintoo'}]);
});

it("should parse multi values", function() {
evaluateItem("http://github.com/?me=you&yomama=andyour,cousintoo", {me: "you", yomama: 'andyour,cousintoo'});
evaluateItem("http://github.com/?me=you&yomama=andyour,cousintoo", [{me: "you"},{yomama: 'andyour,cousintoo'}]);
});

it("should parse with a + in the values", function() {
evaluateItem("http://github.com/?me=you&yomama=andyour+cousintoo", {me: "you", yomama: 'andyour cousintoo'});
evaluateItem("http://github.com/?me=you&yomama=andyour+cousintoo", [{me: "you"}, {yomama: 'andyour cousintoo'}]);
});

it("should parse with an encoded value", function() {
evaluateItem("http://github.com/?me=you%20too&yomama=andyour%20%26%20cousintoo", {me: "you too", yomama: 'andyour & cousintoo'});
evaluateItem("http://github.com/?me=you%20too&yomama=andyour%20%26%20cousintoo", [{me: "you too"}, {yomama: 'andyour & cousintoo'}]);
});

it("should parse multiple keys with the same name", function() {
evaluateItem("http://github.com/?me=tarzan&you=mary&you=jane", [{me: "tarzan"}, {you: "mary"}, {you: "jane"}]);
});

it("should return empty object when there is no query", function() {
evaluateItem("http://github.com", {});
evaluateItem("http://github.com", []);
});

it("should return empty object when there is no query", function() {
evaluateItem("http://github.com/", {});
evaluateItem("http://github.com/", []);
});

it("should return empty object when there is no query", function() {
evaluateItem("http://github.com/?", {});
evaluateItem("http://github.com/?", []);
});

it("should return a key but no value", function() {
evaluateItem("http://github.com/?me=", {me: ''});
evaluateItem("http://github.com/?me=", [{me: ''}]);
});

function evaluateItem(item, expected){
Expand Down