MCPcopy
hub / github.com/django/django / _url

Method _url

django/contrib/staticfiles/storage.py:176–205  ·  view source on GitHub ↗

Return the non-hashed URL in DEBUG mode.

(self, hashed_name_func, name, force=False, hashed_files=None)

Source from the content-addressed store, hash-verified

174 return urlunsplit(unparsed_name)
175
176 def _url(self, hashed_name_func, name, force=False, hashed_files=None):
177 """
178 Return the non-hashed URL in DEBUG mode.
179 """
180 if settings.DEBUG and not force:
181 hashed_name, fragment = name, ""
182 else:
183 clean_name, fragment = urldefrag(name)
184 if urlsplit(clean_name).path.endswith("/"): # don't hash paths
185 hashed_name = name
186 else:
187 args = (clean_name,)
188 if hashed_files is not None:
189 args += (hashed_files,)
190 hashed_name = hashed_name_func(*args)
191
192 final_url = super().url(hashed_name)
193
194 # Special casing for a @font-face hack, like url(myfont.eot?#iefix")
195 # http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
196 query_fragment = "?#" in name # [sic!]
197 if fragment or query_fragment:
198 urlparts = list(urlsplit(final_url))
199 if fragment and not urlparts[4]:
200 urlparts[4] = fragment
201 if query_fragment and not urlparts[3]:
202 urlparts[2] += "?"
203 final_url = urlunsplit(urlparts)
204
205 return unquote(final_url)
206
207 def url(self, name, force=False):
208 """

Callers 2

urlMethod · 0.95
converterMethod · 0.95

Calls 2

unquoteFunction · 0.85
urlMethod · 0.45

Tested by

no test coverage detected