Account for leading slashes in mapDirectory()

Description

Within ModuleConfig.cfc, ACF throws an error when binder.mapDirectory() is passed a packagePath argument with a leading slash.

This causes problems, because the moduleMapping variable includes a leading slash.

This issue was raised on Slack when a user tried to use my sendgridcfc module.

In ColdBox 5.2 on ACF, the following line causes an error: https://github.com/mjclemente/sendgrid.cfc/blob/f1320e378c099eb0f63904677e688f59cad50a7c/ModuleConfig.cfc#L30

The .modules.sendgridcfc.helpers.sender name is not a valid component or interface name.

When the opening slash of the moduleMapping is replaced, the issue is resolved:
packagePath = "#moduleMapping.REreplace( '^/', '' )#/helpers",

I believe it's the line here, that replaces the all slashes with dots, even if it's a leading slash: https://github.com/ColdBox/coldbox-platform/blob/0a3b2ee05d7f8cdd28f549568111b3af9d3ada97/system/ioc/config/Binder.cfc#L298

Activity

Show:
Matthew Clemente
October 30, 2018, 10:29 AM

I think I can resolve this, within Binder.cfc.

When the path is normalized to dot notation, I can remove a leading slash, if present. I think it's safe to assume that a leading slash would never belong, at that point (correct me if I'm wrong).

If this seems like an acceptable approach, I'll put in a PR and you can look at it further.

Luis Majano
November 1, 2018, 8:42 PM

Yes, please do, thanks!

Matthew Clemente
November 2, 2018, 10:23 AM

Assignee

Luis Majano

Reporter

Matthew Clemente

Labels

Components

Fix versions

Affects versions

Priority

Minor
Configure