Skip to content

Commit

Permalink
v0.3.6 Fixed issue with mapsnapshot style regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri Astrakhan committed Apr 28, 2017
1 parent 57974ef commit b42e6b4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graph-shared",
"version": "0.3.5",
"version": "0.3.6",
"description": "Shared code for Wikipedia's Graph extension and Graphoid Service",
"main": "src/VegaWrapper.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/VegaWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ VegaWrapper.prototype.sanitizeUrl = function sanitizeUrl(opt) {
validate(urlParts, 'lon', -180, 180, true);

var query = urlParts.query;
if (query.style && !/^[-_0-9a-z]$/.test(query.style)) {
if (query.style && !/^[-_0-9a-z]+$/.test(query.style)) {
throw new Error('mapsnapshot: if style is given, it must be letters/numbers/dash/underscores only');
}

Expand Down
2 changes: 2 additions & 0 deletions test/testVegaWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ describe('vegaWrapper', function() {
fail('mapsnapshot://sec.org/');
fail('mapsnapshot:///?width=100');
fail('mapsnapshot:///?width=100&height=100&lat=10&lon=10&zoom=5&style=@4');
fail('mapsnapshot:///?width=100&height=100&lat=10&lon=10&zoom=5&style=a$b');
pass('mapsnapshot:///?width=100&height=100&lat=10&lon=10&zoom=5', 'http://maps.nonsec.org/img/osm-intl,5,10,10,100x100@2x.png');
pass('mapsnapshot:///?width=100&height=100&lat=10&lon=10&zoom=5&style=osm', 'http://maps.nonsec.org/img/osm,5,10,10,100x100@2x.png');

fail('tabular://sec.org');
fail('tabular://sec.org/');
Expand Down

0 comments on commit b42e6b4

Please sign in to comment.