Permalink
Browse files

Better util function for finding out local urls

  • Loading branch information...
koenbok committed Jul 15, 2015
1 parent 8097266 commit 6438f758c63aa4bbff0f893f1d6e9ffcdad8d530
Showing with 21 additions and 9 deletions.
  1. +2 −6 framer/Layer.coffee
  2. +19 −3 framer/Utils.coffee
View
@@ -53,7 +53,7 @@ class exports.Layer extends BaseClass
# Special power setting for 2d rendering path. Only enable this
# if you know what you are doing. See LayerStyle for more info.
@_prefer2d = false
@_cacheImage = false
@_cacheImage = true
# We have to create the element before we set the defaults
@_createElement()
@@ -555,11 +555,7 @@ class exports.Layer extends BaseClass
shoudUseImageCache = false
# If this is a file url, we don't use any cache
else if Utils.isLocalUrl(imageUrl)
shoudUseImageCache = false
# If this is a locally served prototype over http (like in studio) we skip the cache
else if imageUrl.indexOf("127.0.0.1") != -1 or imageUrl.indexOf("localhost") != -1
else if Utils.isLocalAssetUrl(imageUrl)
shoudUseImageCache = false
if shoudUseImageCache is false
View
@@ -296,11 +296,27 @@ Utils.isTablet = ->
Utils.isMobile = ->
Utils.isPhone() or Utils.isTablet()
Utils.isLocal = ->
Utils.isLocalUrl window.location.href
Utils.isFileUrl = (url) ->
return _.startsWith(url, "file://")
Utils.isRelativeUrl = (url) ->
return true if _.startsWith(url, ".")
return true if _.startsWith(url, "./")
return true if _.startsWith(url, "../")
return false
Utils.isLocalServerUrl = (url) ->
return url.indexOf("127.0.0.1") != -1 or url.indexOf("localhost") != -1
Utils.isLocalUrl = (url) ->
url[0..6] == "file://"
return true if Utils.isFileUrl(url)
return true if Utils.isLocalServerUrl(url)
return false
Utils.isLocalAssetUrl = (url) ->
return true if Utils.isLocalUrl(url)
return true if Utils.isRelativeUrl(url) and Utils.isLocalUrl(window.location.href)
return false
Utils.isFramerStudio = ->
navigator.userAgent.indexOf("FramerStudio") != -1

0 comments on commit 6438f75

Please sign in to comment.