12
\$\begingroup\$

Background

Following on from this question where it was decided that, as we define languages by their implementation, JavaScript solutions could include a requirement that they be run under a specific domain. This allows us to use, for example, /questions/[id]?site=codegolf instead of //api.stackexchange.com/questions/[id]?site=codegolf to save a few bytes.

In a recent solution I took this a (small) step further, requiring that it be run at the root level of api.stackexchange.com and using questions/[id]?site=codegolf to save another byte.

Proposal

But that then got me to thinking: if we can require a specific domain then we could, by extension, be able to require a specific path, with the above example becoming simply [id]/?site=codegolf if run from api.stackexchange.com/questions/.

Personally, I feel that it's pushing things too far but couldn't come up with a legitimate argument against allowing it so decided to post this question to garner some thoughts from the community and, hopefully, reach a consensus on it.

\$\endgroup\$
  • \$\begingroup\$ I think it should work similar to running from a custom directory, but I can't remember how that works. \$\endgroup\$ – NoOneIsHere Sep 21 '17 at 17:28
  • \$\begingroup\$ Really, this should be a comment on the linked question, or a separate answer outlining the problems with accepting the current answer - the question is basically the same. I for one have upvoted the 'second' answer, seeing how problematic an exact definition of the 'first' answer is. \$\endgroup\$ – Sanchises Sep 22 '17 at 14:18
  • 4
    \$\begingroup\$ Possible duplicate of Can JS answers require the code to be run at a certain domain? \$\endgroup\$ – Sanchises Sep 22 '17 at 14:18
  • 5
    \$\begingroup\$ I don't see how this is a duplicate. This question is a follow-up to that question that asks if full paths can be specified instead of only a domain. The proposed duplicate is even linked to in the question. \$\endgroup\$ – LyricLy Sep 23 '17 at 0:40
  • 1
    \$\begingroup\$ This probably applies to running locally too, e.g. a bash script that only works if your current directory is /usr ? \$\endgroup\$ – Neil Sep 24 '17 at 0:11
  • \$\begingroup\$ You definitely shouldn't be allowed to specify a path that's not, say, on a static sitemap. Otherwise every answer becomes eval(base64decode(window.location.pathname[5,5432]))) \$\endgroup\$ – histocrat Sep 28 '17 at 20:34
  • \$\begingroup\$ @histocrat Why use .pathname when you can use .search? \$\endgroup\$ – Neil Oct 1 '17 at 14:21

You must log in to answer this question.

Browse other questions tagged .