Skip to content

htaccess.json file whitespace issues #14

@ronaldtse

Description

@ronaldtse

A normal htaccess file looks like this:

user1:ajdkahsdakdjshakd
user2:akjshdkasjdhadkjsh

In the htaccess.json read by the Lambda function, it needs to look like this:

{
  "htpasswd": "foobar:$2y$05$1h9cwwFusLcZCIUpdM7Gke.ei1E2QV6ORH/ZmvbR4h2tDGHb7q8lW\nzeebaa:$2y$05$aWBOi47GEOOoNB/ZUgdPY.NukDalyc.Bvn.S0aOlKDD9wp0R9mQHm",
...
}

But in the JSON, this will fail:

{
  "htpasswd": "foobar:$2y$05$1h9cwwFusLcZCIUpdM7Gke.ei1E2QV6ORH/ZmvbR4h2tDGHb7q8lW
zeebaa:$2y$05$aWBOi47GEOOoNB/ZUgdPY.NukDalyc.Bvn.S0aOlKDD9wp0R9mQHm",
...
}

Originally I wanted to do this:

{
  "htpasswd": "${file("htaccess")}",
...
}

But this problem prevents a direct substitution of the htaccess text and the JSON. The workaround is:

{
  "htpasswd": "${replace(file("htaccess"),"\n","\\n")}",
...
}

Can we make the function less whitespace-fussy by allowing linebreaks in addition to \n?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions