Ticket #1305 (closed bug: duplicate)

Opened 5 years ago

Last modified 5 years ago

Multi-file include breaks if there are query parameters specified

Reported by: openlayers Owned by:
Priority: major Milestone: 2.6 Release
Component: general Version: 2.5
Keywords: Cc: beau@…
State: Review

Description

I'm using OpenLayers with Drupal, and included JS flies sometimes get query parameters like ?m appended to the end.

In OpenLayers.js I added a small test to _getScriptLocation to strip these off before comparing.

--- OpenLayers-2.5/lib/OpenLayers.js    Tue Oct  9 13:45:37 2007
+++ ../lib/OpenLayers.js        Mon Jan 28 01:59:02 2008
@@ -42,7 +42,14 @@
             for (var i = 0; i < scripts.length; i++) {
                 var src = scripts[i].getAttribute('src');
                 if (src) {
-                    var index = src.lastIndexOf(scriptName);
+                    // remove any query parameters
+                    var index = src.lastIndexOf("?");
+
+                    if (index > -1) {
+                       src = src.slice(0, index);
+                    }
+
+                    index = src.lastIndexOf(scriptName);
                     // is it found, at the end of the URL?
                     if ((index > -1) && (index + scriptName.length == src.length)) {
                         scriptLocation = src.slice(0, -scriptName.length);

Change History

Changed 5 years ago by openlayers

Forgot to mention that this breaks because I've got lib in a subdirectory and when this code returns a null scriptLocation the script tags are generated in the top-level directory.

Changed 5 years ago by crschmidt

  • milestone set to 2.6 Release

Can you turn this into a patch file?  http://trac.openlayers.org/wiki/CreatingPatches If so, I'll check it out.

Changed 5 years ago by ahocevar

  • status changed from new to closed
  • resolution set to duplicate

This is a duplicate of #1263. There is also a patch which needs more work.

Note: See TracTickets for help on using tickets.