[OpenLayers-Trac] [OpenLayers] #3642: Layer switcher button broken
(_getScriptLocation) in OpenLayers-2.12-rc1
OpenLayers
trac-20090302 at openlayers.org
Wed Apr 4 11:03:56 EDT 2012
#3642: Layer switcher button broken (_getScriptLocation) in OpenLayers-2.12-rc1
---------------------+------------------------------------------------------
Reporter: jpfiset | Owner:
Type: bug | Status: new
Priority: minor | Milestone: 2.13 Release
Component: general | Version: 2.11
Keywords: | State:
---------------------+------------------------------------------------------
When using the single file version of OpenLayers, the layer selector
button is broken (the path to the file layer-switcher-maximize.png is
invalid). However, when using the developer's version of the library
(lib/OpenLayers.js), the button is shown properly.
The issue comes from the fact that the routine to compute the script
location in SingleFile.js was modified and the regex, in some
circumstances, matches the wrong portion for the script path.
If a portion of the path to the single file library OpenLayers.js contains
the pattern "OpenLayers", then the regex matches the wrong portion of the
path. Here are some examples.
"js/OpenLayers.js" matches correctly.
"js/OpenLayers/OpenLayers.js" does not match correctly.
The fix is to change the regex in SingleFile.js from
var r = new RegExp("(^|(.*?\\/))(OpenLayers.*?\\.js)(\\?|$)")
to
var r = new RegExp("(^|(.*?\\/))(OpenLayers[^\\/]*?\\.js)(\\?|$)")
This modification prevents the matching of the path separator within the
library name.
Here is the same modification, but in a patch form:
diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js
index 234c9c0..ae34ef9 100644
--- a/lib/OpenLayers/SingleFile.js
+++ b/lib/OpenLayers/SingleFile.js
@@ -25,7 +25,7 @@ var OpenLayers = {
* {String} Path to this script
*/
_getScriptLocation: (function() {
- var r = new RegExp("(^|(.*?\\/))(OpenLayers.*?\\.js)(\\?|$)"),
+ var r = new
RegExp("(^|(.*?\\/))(OpenLayers[^\\/]*?\\.js)(\\?|$)"),
s = document.getElementsByTagName('script'),
src, m, l = "";
for(var i=0, len=s.length; i<len; i++) {
--
Ticket URL: <http://trac.openlayers.org/ticket/3642>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list