<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic javascript issue with url object in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/javascript-issue-with-url-object/m-p/208026#M161156</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all, I just found a funny issue with the url.extension object on the base context in my web script.&amp;nbsp; The javascript native shift() function doesn't work correctly on the url.extension object, but it works correctly elsewhere.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm calling my script with a path like: /mycomp/services/imageThinger/dog/cat/ball/bat&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so the url.extension would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dog/cat/ball/bat&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I want to shift() the storeId off the front of the array, and use the rest as the file path in the store.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so in my web script I say:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var testArray = url.extension.split("/");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model.testLengthBefore = testArray.length;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; testArray.shift();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model.testLengthAfter = testArray.length;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And they both come out the same!!&amp;nbsp; What's more, the first element has indeed been shifted off the front of the array, but the last one has been duplicated mysteriously, so when I join them back up I get a path that looks like: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cat/ball/bat/bat&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could understand if the split() function wasn't there, and I was operating on some strange java object behind the scenes, but you'd think that calling split() would give me some old array implementation with a working shift function, whether it was just javascript or java.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So a simple fix for this is to replace the first two lines with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var test = "" + url.extension; //type coercion into a normal js string object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var testArray = test.split("/");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then the length decreases by one as expected and everything works.&amp;nbsp; I wonder what sort of object url.extension really is, to be doing this weird thing, and whether it's a fundamental Rhino bug or just some weirdness in the API objects used.&amp;nbsp; I searched Alfresco JIRA for it and found nothing with "web script" and "shift" matching my bug.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Nov 2008 04:42:04 GMT</pubDate>
    <dc:creator>damonsmith</dc:creator>
    <dc:date>2008-11-17T04:42:04Z</dc:date>
    <item>
      <title>javascript issue with url object</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/javascript-issue-with-url-object/m-p/208026#M161156</link>
      <description>Hi all, I just found a funny issue with the url.extension object on the base context in my web script.&amp;nbsp; The javascript native shift() function doesn't work correctly on the url.extension object, but it works correctly elsewhere.I'm calling my script with a path like: /mycomp/services/imageThinger/do</description>
      <pubDate>Mon, 17 Nov 2008 04:42:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/javascript-issue-with-url-object/m-p/208026#M161156</guid>
      <dc:creator>damonsmith</dc:creator>
      <dc:date>2008-11-17T04:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: javascript issue with url object</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/javascript-issue-with-url-object/m-p/208027#M161157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm seeing the same thing with document.name.&amp;nbsp; Had to do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; var filename = new String(document.name);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; var folder = document.parent;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; var elements = filename.split(".");&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;In order for the split to work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2009 17:10:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/javascript-issue-with-url-object/m-p/208027#M161157</guid>
      <dc:creator>opoplawski</dc:creator>
      <dc:date>2009-03-16T17:10:17Z</dc:date>
    </item>
  </channel>
</rss>

