Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Update LAB.src.js #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

huhai463127310
Copy link

to support chrome-extension

to support chrome-extension
@getify
Copy link
Owner

getify commented Feb 11, 2014

What's the motivation for this change? It seems you are saying that chrome extensions have urls like "---://some.tld/..." with literal - dashes instead of http/https/file/etc? That seems bizarre, if I'm interpreting your code change correctly.

Also, shouldn't you just be able to use LABjs with explicit URLs, or by setting the BasePath configuration, thereby ignoring any of the automatic URL negotiation?

@huhai463127310
Copy link
Author

The location.href mybe like this "chrome-extension://kkpoepbkjgkbbaahccibkoibcnfbbdbc/index.html" in an chrome extension app.When LAB.js was used in chome extension app.The \w in the regexp of line 19th will lead an error, because of that the character "-" will not match \w.The error message is:
Uncaught TypeError: Cannot read property '0' of null LAB.js:19

[source code]
18 root_page = /^[^?#]*//.exec(location.href)[0]
19 root_domain = /^\w+:///?[^\/]+/.exec(root_page)[0]

in this case:
root_page="chrome-extension://kkpoepbkjgkbbaahccibkoibcnfbbdbc/"

I use [\w|-] instead of \w to support pattern like "chrome-extension" .

@getify
Copy link
Owner

getify commented Feb 12, 2014

Interesting. This may be related to #93. I might make a separate fork branch with slight tweaks that deal with non-standard/unexpected location values in a more robust way.

I'm not sure when/if those changes would roll into the main branch and necessitate an update (not sure I think these niche cases justify a 2.0.4 patch release). But at least the separate branch would provide an alternate copy for those who need to use LABjs in those unusual conditions.

I think there will someday be a LAB 2.1 release (or whatever), as over the years several tiny things have been requested. None of them are enough to justify a new release, but taken altogether, I think we'll eventually get to the point where another release comes out, and we'll certainly pull this one in at that time.

@huhai463127310
Copy link
Author

3q for your patient reply

@roplet
Copy link

roplet commented Apr 20, 2016

JFYI,

I am also experiencing this issue in Apache Cordova applications for Windows Phone. The urls there have a dash in the 'ms-appx' prefix. For instance: ms-appx://com.mycompany.myapp/www/index.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants